[Sussex] C++ question

Geoff Teale Geoff.Teale at claybrook.co.uk
Mon Jan 20 13:53:01 UTC 2003


> Working at home; get a life ;-)

Well, what else am I gonna do when it's 2am and I can't sleep? ;P
 
> How often are you re-sizing the array?  If this is happening 
> a lot there
> are two options:
> 
>   1).  If memory size is no problem (this is not an embedded 
> system) then 
>        double the array size each time you have to resize it. 
>  This is the
>        way classes like java.util.Vector work.  Add methods 
> to pre-size the
>        array, shrink to fit, and set the grow size.

Already doing this.. ..good advice though, I'm not green enough to go about
doing memory allocations willy nilly..
 
>   2).  Use a linked list.  Slowwer to search, but very fast to add and
> remove 
>        on the fly.  As you said this was a C++ question not a 
> C question
> I'll
>        assume that you could hold a flag that marks if the 
> pointer array is
>        dirty or not with the (master) linked list structure.  
>  Then you need
>        only re-size the array when needed - don't bother 
> keeping the array
> in
>        step with the linked list.

Hadn't really thought of this - there is really no reason why I couldn't do
this for my purposes.  Effectively I'm writing a simplified wrapper for Xlib
as part of a little something I'm rustling up, I have an "Application"
object which (in order to present some higher level functionality) needs to
present all of its "Window" objects through a user-searchable data
structure.  This may end up being an iterator so the internal data structure
doesn't really matter that much - though the point here is to keep it simple
for the user (coders) point of view rather than rewriting QT!!

Shall give this some thought - does it really give me any advantages?

<deletia>
-- 
geoff.teale at claybrook.co.uk
tealeg at member.fsf.org

"and the mighty multinationals
have monopolized the oxygen
so it's as easy as breathing
for us all to participate"
- Ani DiFranco "Your next bold move"



The above information is confidential to the addressee and may be privileged.  Unauthorised access and use is prohibited.
 
Internet communications are not secure and therefore this Company does not accept legal responsibility for the contents of this message.
 
If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful.
 
Claybrook Computing Limited is a subsidiary of Claybrook Computing (Holdings) Limited
Registered Office: Abbey House. 282 Farnborough Road, Farnborough, Hampshire GU14 7NJ
Registered in England and Wales No 1287205
 
A Hogg Robinson plc company





More information about the Sussex mailing list