View previous topic :: View next topic |
Author |
Message |
neochrome32
Joined: 09 Jun 2013 Posts: 153
|
list collection class help |
Posted: Thu Sep 18, 2014 6:52 am |
|
|
Sorry for the topic not being clear :(
not sure how else to describe this...
im trying to make a dynamic list.
abit like
List.Add(&object);
List.Remove(&object);
List.MoveUp(&object);
List.MoveDown(&object);
need some sort of like this...
but im actually blanking on it!
anyone got anything close to this?
thanks for any help |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19382
|
|
Posted: Thu Sep 18, 2014 8:22 am |
|
|
Since C is not class based, you are going to have to do this all yourself.
There has been stuff published in the past, that may possibly be ported, but you really should be asking whether you are actually doing the right thing here.
Look at:
<http://stackoverflow.com/questions/1403890/how-do-you-implement-a-class-in-c>
and look for the GObject library. |
|
![](templates/subSilver/images/spacer.gif) |
neochrome32
Joined: 09 Jun 2013 Posts: 153
|
|
Posted: Thu Sep 18, 2014 8:40 am |
|
|
hmm not easily done for me, im not a bright as you Ttelmah.. lol
ok seems like this is over kill for something i wanna do, im trying to make a GUI, but need to make a way of "push" "pop"
so its looking like im gonna have to make a "preloaded batch" |
|
![](templates/subSilver/images/spacer.gif) |
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Thu Sep 18, 2014 11:24 am |
|
|
Maybe you need to take a step backwards.
Seems to me, you've got something you want to do, and have already decided on a solution (or approach to the problem).
Give us more explicit detail and you might be offered better alternatives.
Mike |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19382
|
|
Posted: Thu Sep 18, 2014 12:22 pm |
|
|
malloc, calloc, and free, allow you to allocate a memory area for 'something' (whatever you want).
Then just use an array of pointers to these areas. Either a circular buffer (for FIFO), or linear buffer (for LIFO). |
|
![](templates/subSilver/images/spacer.gif) |
neochrome32
Joined: 09 Jun 2013 Posts: 153
|
|
Posted: Thu Sep 18, 2014 1:01 pm |
|
|
ohh, never thought of that, now with the 58k ram is available on the chip im using...
this would work well ... this might work! thank you!
looking into .c though seems that it only supports up to 7 steps?? |
|
![](templates/subSilver/images/spacer.gif) |
|