|
|
Public Members
Generic array template, for objects and non-objects. Much better
than manys other implementations.
Arrays can contain empty slots that do not point to an existing
object. Some methods can also return NULL references to objects,
which is rather special behaviour for C++ references. You can
check the nullness of an object by the isnull(const Object&)-function in object.h.
if (isnull(myArray[5])) {...}
Lower bound of the array. DO NOT MODIFY! This should be an access method, but is not.
Upper bound of the array. DO NOT MODIFY! This should be an access method, but is not.
Size of the array. DO NOT MODIFY! This should be an access method, but is not.
Creates an array of the given size. If no size is given, creates an empty array. NOTE: The objects are not created with this constructor, but only when they are accessed first time.
Creates an array with the given lower and upper bounds. NOTE: The objects are not created with this constructor, but only when they are accessed first time.
Creates an array with the given lower and upper bounds. If the array previously has any content, that content is destroyed. NOTE: The objects are not created with this method, but only when they are accessed first time.
Creates an array of the given size. If the array previously has any content, that content is destroyed. NOTE: The objects are not created with this method, but only when they are accessed first time.
Destructor destroys all the objects contained by the Array.
Destroys all the objects in the Array, but does NOT change the size.
Adds the given object to the end of the array; increments the size of the array by one. NOTE: Takes the ownership of the object.
Adds the given object to the end of the array; increments the size of the array by one. NOTE: Does not takes the ownership of the object, but just copies it using the copy constructor.
Puts the given object to the given location. Old item in the same index location is destroyed. NOTE: Takes the ownership of the object. Parameters:
Puts the given object to the given location. Old item in the same index location is destroyed. NOTE: Does not takes the ownership of the object, but just copies it using the copy constructor. Parameters:
Adds the given object to any NULL location in the array; if no null locations exists, the object is added to the end of the array just like in add. NOTE: Takes the ownership of the object.
Returns a reference to the loc:th item in the Array. If the item does not exist (is null), it is created. Throws 'assertion_failed' if the index is out of bounds. Const version.
Returns a reference to the loc:th item in the Array. If the item does not exist (is null), it is created. Throws 'assertion_failed' if the index is out of bounds. Non-const version.
Returns a pointer to the loc:th item in the Array. If the item does not exist, a NULL is returned. Throws 'assertion_failed' if the index is out of bounds. Const version.
Returns a pointer to the loc:th item in the Array. If the item does not exist, a NULL is returned. Throws 'assertion_failed' if the index is out of bounds. Non-const version.
Finds the given object in the Array and returns it's index number, or -1 if not found.
Destroys the object with the given index number from the array. Does not fill the hole, but leaves it NULL.
Destroys the object with the given index number from the Array, and fills the hole by shifting the rest of the items one index downwards.
Removes the object with the given index from the Array, but does NOT destruct the object; just removes the reference to it.
Changes the bounds of the Array to the given ones. New size is calculated accordingly. Reserves or destructs as needed.
Standard =-operator. Performs deep copy. >>
Serialization support for the Array.
Serialization support for the Array.
Implementation for Object. Checks the integrity of the Array.
Sorts the values in the Array. NOTE: The contained objects MUST inherit Comparable, and be of the same class!
|