class ArrayBase: protected _ArrayBase

Dynamic array base class.

Inheritance:


Public Methods

[more]int size() const
Returns the number of elements in the array
[more]int lbound() const
Returns the lower bound of the valid subscript range.
[more]int hbound() const
Returns the upper bound of the valid subscript range.
[more]void empty()
Erases the array contents.
[more]void touch(int n)
Extends the subscript range so that is contains n.
[more]void resize(int hibound)
Resets the valid subscript range to 0---hibound.
[more]void resize(int lobound, int hibound)
Resets the valid subscript range to lobound---hibound.
[more]void shift(int disp)
Shifts the valid subscript range.
[more]void del(int n, unsigned int howmany=1)
Deletes array elements.


Documentation

Dynamic array base class. This is an auxiliary base class for DArray and TArray implementing some shared functions independent of the type of array elements. It's not supposed to be constructed by hands. Use DArray and TArray instead.
oint size() const
Returns the number of elements in the array

oint lbound() const
Returns the lower bound of the valid subscript range.

oint hbound() const
Returns the upper bound of the valid subscript range.

ovoid empty()
Erases the array contents. All elements in the array are destroyed. The valid subscript range is set to the empty range.

ovoid touch(int n)
Extends the subscript range so that is contains n. This function does nothing if n is already int the valid subscript range. If the valid range was empty, both the lower bound and the upper bound are set to n. Otherwise the valid subscript range is extended to encompass n. This function is very handy when called before setting an array element:
       int lineno=1;
       DArray<GString> a;
       while (! end_of_file()) { 
       a.touch[lineno]; 
       a[lineno++] = read_a_line(); 
       }
       

ovoid resize(int hibound)
Resets the valid subscript range to 0---hibound. This function may destroy some array elements and may construct new array elements with the null constructor. Setting hibound to -1 resets the valid subscript range to the empty range.
Parameters:
hibound - upper bound of the new subscript range.

ovoid resize(int lobound, int hibound)
Resets the valid subscript range to lobound---hibound. This function may destroy some array elements and may construct new array elements with the null constructor. Setting lobound to 0 and hibound to -1 resets the valid subscript range to the empty range.
Parameters:
lobound - lower bound of the new subscript range.
hibound - upper bound of the new subscript range.

ovoid shift(int disp)
Shifts the valid subscript range. Argument disp is added to both bounds of the valid subscript range. Array elements previously located at subscript x will now be located at subscript x+disp.

ovoid del(int n, unsigned int howmany=1)
Deletes array elements. The array elements corresponding to subscripts n...n+howmany-1 are destroyed. All array elements previously located at subscripts greater or equal to n+howmany are moved to subscripts starting with n. The new subscript upper bound is reduced in order to account for this shift.
Parameters:
n - subscript of the first element to delete.
howmany - number of elements to delete.


Direct child classes:
ArrayBaseT

Alphabetic index HTML hierarchy of classes or Java


DjVu is a trademark of LizardTech, Inc.
All other products mentioned are registered trademarks or trademarks of their respective companies.