CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

list collection class help

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
neochrome32



Joined: 09 Jun 2013
Posts: 153

View user's profile Send private message Visit poster's website

list collection class help
PostPosted: Thu Sep 18, 2014 6:52 am     Reply with quote

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
Ttelmah



Joined: 11 Mar 2010
Posts: 19540

View user's profile Send private message

PostPosted: Thu Sep 18, 2014 8:22 am     Reply with quote

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.
neochrome32



Joined: 09 Jun 2013
Posts: 153

View user's profile Send private message Visit poster's website

PostPosted: Thu Sep 18, 2014 8:40 am     Reply with quote

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"
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Thu Sep 18, 2014 11:24 am     Reply with quote

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
Ttelmah



Joined: 11 Mar 2010
Posts: 19540

View user's profile Send private message

PostPosted: Thu Sep 18, 2014 12:22 pm     Reply with quote

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).
neochrome32



Joined: 09 Jun 2013
Posts: 153

View user's profile Send private message Visit poster's website

PostPosted: Thu Sep 18, 2014 1:01 pm     Reply with quote

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??
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group