loopedArray (C) 2000 Robert Peake
Released under GNU Lesser Public Licesne
ABOUT:
The loopedArray object simulates a "looped" array data type that loops such
that all indexes of (n*sizeof(loopedArray) + k) returns the same element as
indexes of k for all integers k, n.
The loopedArray object attempts to emulate many of the standard array functions
with this paradigm, and adds two additional functions, "before," and "after,"
which return the element before and after a given element, respecting the
property above.
API:
void initialize(variable) :
If initialize is given an array, it will use the array
as the basis for the loopedArray,
otherwise it will attempt to add what it is given
to the loopedArray.
void add(variable) :
add adds the given variable to the end of the array
boolean removeElement(variable) :
removeElement removes the first matching element found from the array
returns true if at least one instance of the element is found,
returns false otherwise.
boolean removeAllElement(variable) :
removeAllElement removes all instances the element from the array
returns true if at least one instance of the element is found,
returns false otherwise.
boolean removeIndex(int) :
removeIndex removes the element at the given index from the array
returns true if element exists at index, false otherwise
variable indexof(variable) :
indexof returns the first index of the given element in the
loopedArray, false if the element does not exist in the loopedArray.
int numelements() :
numelements returns the number of elements in the loopedArray
variable elementat(int) :
elementat returns the element at the index of the loopedArray, looping
such that (n*sizeof(loopedArray) + k) returns the same element as k
for all integers k, n.
variable after(variable) :
after returns the next element after the given element in the loop
or false if the element does not exist in the loopedArray
variable before(variable) :
before returns the element before the given element in the loop
void printAll(string) :
printAll outputs all elements in the array, separated by a delimiter
ADDENDUM
This software is released as-is, with no implications of warranty or fiteness
to a particular use. The author implies no obligation to provide techincal
support for this software on the part of himself or his company.
Robert@MSIA.org
|