Single-Allocation Variable-Sized Array
    Nordlöw via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Wed May 18 14:28:56 PDT 2016
    
    
  
What's the preferred way in D to implement single-allocation 
variable-sized arrays such as
/** Single-Allocation Array. */
struct ArrayN
{
     ubyte length;  // <= maxLength
     size room;     // allocated length
     ubyte[0] data; // `room` number of bytes follows
}
where insertion/deletion typically is done via
     ArrayN* pushBack(ArrayN*, ubyte element);
     ArrayN* popBack(ArrayN*);
which, when needed, will reallocate a new larger/smaller `ArrayN`
?
Further, what's the official name for this structure?
    
    
More information about the Digitalmars-d-learn
mailing list