data structures in arduino

Is there any way to implement some of the data structures such as linklist,tree,graph or some thing in arduino???

it basically will need pointers and dynamic memory allocation.....

any way????????experts??????????? :sunglasses:

You have a plain vanilla C++ where you can use pointers as usual. You can also use new, malloc etc if you want.

However, given that you just have 2 kB of RAM, no operating system and just one task running, much of the classic memory management is often pointless or not efficient enough and you're better off allocating the little available memory yourself in the way best for your use-case.

It's a bit like making mixed pickles out of 2 pieces of pickles. In theory you can mix them, but will you be able to tell the difference.

Korman

i just want to know if i can do so.....thats all....

i think dynamic memory allocation using the common "new" or "malloc" is mostly needed for small memory...
for example
if we are declaring an array a[200] and only taking 10 locations then rest of the part is wasted..i think u know that cormen. :wink:

That realisation is step one, until you realise further that you have so little memory, that you're even better off with deciding beforehand how to fail and what kind of situation you don't handle properly and not leave it to dynamic memory management to fail for you. Very often handling a known amount of memory is easier than handling failed calls to new and malloc. And don't forget, your program is all alone out there and doesn't have the option of quitting. It'll just go on running with whatever garbage data that was availble. That's one of the big differences when working with microcontroller.

Korman

I know my program is alone....with out any underlying kernel that make the memory management .....but the program have full control over the memory and can do any at the machine level and also the amount of garbage will be small which could handled...........

but did u think actually my program is alone there???

no its not alone .....because we are using arduino

if we are using direct assembly or pseudo code for the atmega then only it will be alone. :smiley:

no its not alone .....because we are using arduino

if we are using direct assembly or pseudo code for the atmega then only it will be alone.

And too deepen your understanding, what is that infamous Arduino?
A bootloader to load new programs and set up the hardware, which which your program won't interact. A substitute for main() which first calls setup() and the loop() in an endless while-loop and provides no other support. A static library with a bunch of useful functions your program can call. The only services the arduino really provides is the updating of millis() and if you use it the interrupt driven receiving of Serial. That's it. So your program is alone out there, it wouldn't look much different if you wrote it in assembler. If you want to talk with a little competence about those things, I strongly advise you to look at the provides library source of the Arduino and play around with avr-objdump. If you don't want to bother, please don't run around spewing unfound assumption. Facts are so close at hand, please use them.

Korman

ok am wrong........
is there any way to write programs from any other IDE other than arduino?

There is a plugin for Eclipse, I think there was also something for Visual Studio. Another common option is to use a real editor and just use the IDE to upload it. Someone took the pain to create a makefile so you can compile and upload directly from the command line. For me, using vi and compiling with the IDE is good enough, so I never checked out the alternatives.

Korman

I have problem with the IDE's because it will not start simply wen my wifi or bluetooth is on.....its so embarrassing....

am using vista...its because of the COM port conflict....any idea how to solve??? ...

i think am starting a post on that problem...

No clue, I'm not into that Windows stuff. However search in the forums first, that may be a common problem. Another cause for the problem may be a shield using Pin0 or Pin1 (transmit and receive for the serial). In this case, using another IDE won't resolve anything, because all of them use avr-dude to transmit the data including the Arduino one.

Korman

ok............... :-[