Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

NBaseArray Class Reference

#include <NArray.h>

Inheritance diagram for NBaseArray:

NArray InstArray

List of all members.


Public Members

 NBaseArray (UInt32 eltSize)
 NBaseArray (UInt32 eltSize, Int size, Int alloc = kFirstNAllocation)
 NBaseArray (const NBaseArray &array)
 ~NBaseArray ()
Int NumItems () const
Number of items in the array.

NBaseArray& operator= (const NBaseArray &array)
Assignment!

Void Pop ()
Delete top of stack.

Void Clear ()
Delete all items.

Void PreAllocate (UInt32 numItems)
Preallocate space for array.

Void SetSize (Int newSize)
Set array size directly.

Void Add (Int n = 1)
Add n items to the array.

Void Shrink (Int n = 1)
shrink the array by n items.

Void Insert (Int i, Int n = 1)
Insert n items at i.

Void Delete (Int i, Int n = 1)
Delete n items at i.

Void ShrinkWrap ()
Ensure allocated space = space being used.

Void Append (const NBaseArray &a)
Append array to array.

Void SwapWith (NBaseArray &a)
swaps this array with a.

Void Replace (NBaseArray &a)
Replace this array with a & clear a.

Void MemMap (const Char* filename)
Void WriteFile (const Char *filename)
Void ReadFile (const Char *filename)
Int FWrite (FILE *file)
Int FRead (FILE *file)
Void Attach (Void *ptr, Int numItems, Bool shared = false)
UInt32 EltSize ()

Protected Members

Void Grow ()
Byteitem
pointer to array.

UInt32 items
items in the array.

UInt32 allocated
number of items we have space allocated for.

UInt32 eltSize

Detailed Description

Note: We grow the array in size exponentially. That is, every time we need to increase the size of the array, we double its size rather than increasing it by a fixed amount. For appending n items to an empty list, this gives us O(n) copies, as opposed to the O(n^2) copies required if we increment by a fixed size each time.

It would be useful to have an array data structure that utilises a tree of fixed-size arrays, thus trading off access time (const vs. o(logbn)) and poor insert/delete performance against eliminating copies.

Definition at line 30 of file NArray.h.


Constructor & Destructor Documentation

NBaseArray::NBaseArray (UInt32 es) [inline]

Definition at line 138 of file NArray.h.

NBaseArray::NBaseArray (UInt32 es, Int size, Int alloc = kFirstNAllocation)

Definition at line 33 of file NArray.cc.

NBaseArray::NBaseArray (const NBaseArray & array)

Definition at line 44 of file NArray.cc.

NBaseArray::~NBaseArray ()

Definition at line 55 of file NArray.cc.


Member Function Documentation

Void NBaseArray::Add (Int n = 1)

Add n items to the array.

Definition at line 107 of file NArray.cc.

Void NBaseArray::Append (const NBaseArray & a)

Append array to array.

Definition at line 178 of file NArray.cc.

Void NBaseArray::Attach (Void * ptr, Int numItems, Bool shared = false)

Definition at line 268 of file NArray.cc.

Void NBaseArray::Clear () [inline]

Delete all items.

Definition at line 153 of file NArray.h.

Void NBaseArray::Delete (Int i, Int n = 1)

Delete n items at i.

Definition at line 130 of file NArray.cc.

UInt32 NBaseArray::EltSize () [inline]

Definition at line 75 of file NArray.h.

Int NBaseArray::FRead (FILE * file)

Definition at line 258 of file NArray.cc.

Int NBaseArray::FWrite (FILE * file)

Definition at line 250 of file NArray.cc.

Void NBaseArray::Grow () [protected]

Definition at line 159 of file NArray.cc.

Void NBaseArray::Insert (Int i, Int n = 1)

Insert n items at i.

Definition at line 118 of file NArray.cc.

Void NBaseArray::MemMap (const Char * filename)

Int NBaseArray::NumItems () const [inline]

Number of items in the array.

Definition at line 143 of file NArray.h.

Void NBaseArray::Pop () [inline]

Delete top of stack.

Definition at line 148 of file NArray.h.

Void NBaseArray::PreAllocate (UInt32 numItems)

Preallocate space for array.

Definition at line 77 of file NArray.cc.

Void NBaseArray::ReadFile (const Char * filename)

Definition at line 229 of file NArray.cc.

Void NBaseArray::Replace (NBaseArray & a)

Replace this array with a & clear a.

Definition at line 203 of file NArray.cc.

Void NBaseArray::SetSize (Int newSize)

Set array size directly.

Definition at line 101 of file NArray.cc.

Void NBaseArray::Shrink (Int n = 1)

shrink the array by n items.

Definition at line 112 of file NArray.cc.

Void NBaseArray::ShrinkWrap ()

Ensure allocated space = space being used.

Definition at line 142 of file NArray.cc.

Void NBaseArray::SwapWith (NBaseArray & a)

swaps this array with a.

Definition at line 192 of file NArray.cc.

Void NBaseArray::WriteFile (const Char * filename)

Definition at line 217 of file NArray.cc.

NBaseArray & NBaseArray::operator= (const NBaseArray & array)

Assignment!

Definition at line 60 of file NArray.cc.


Member Data Documentation

UInt32 NBaseArray::allocated [protected]

number of items we have space allocated for.

Definition at line 81 of file NArray.h.

UInt32 NBaseArray::eltSize [protected]

Definition at line 82 of file NArray.h.

Byte * NBaseArray::item [protected]

pointer to array.

Definition at line 79 of file NArray.h.

UInt32 NBaseArray::items [protected]

items in the array.

Definition at line 80 of file NArray.h.


The documentation for this class was generated from the following files:
Generated at Sat Aug 5 00:16:34 2000 for Class Library by doxygen 1.1.0 written by Dimitri van Heesch, © 1997-2000