- Inherits from:
- Object
- Conforms to:
- DComparable, DParsable, DSizeable, DTextable
- Declared in:
- DIntArray.h
Object
|
+---DIntArray
Class Description
The DIntArray class implements an one dimensional array of integers. It is of
course possible to create an array of integers with the classes DArray and DInt,
but this is not very efficient and a little bit clumsy. This class also implements some
statistical methods.
- Last modified:
- 31-Oct-2007 (DIntArray.h)
Instance Variables
- private unsigned long _size
- the allocated size for the data
- private unsigned _extra
- the extra size amount
- private unsigned long _length
- the length of the data
- private int *_array
- the array of integers
- Constructors
- - (DIntArray *) init
- Initialise to an empty array
- Returns:
- the object
- - (DIntArray *) init :(const int *) ints :(unsigned long) length
- Initialise the object with integers
- Parameters:
- ints - the integers
length - the length of the integers
- Returns:
- the string object
- Copy related methods
- - shallowCopy
- Do a shallow copy of the array
- Returns:
- the object
- Deconstructor
- - free
- Free the object
- Returns:
- the object
- Member methods
- - (const int *) array
- Return the pointer to the array of integers
- Returns:
- the pointer to the array
- - (BOOL) isEmpty
- Check if the array is empty
- Returns:
- Is it empty ?
- - (unsigned long) length
- Return the length of the array
- Returns:
- the length
- Size methods
- - (DIntArray *) extra :(unsigned) extra
- Set the amount of extra size increase if the size must be extended
- Parameters:
- extra - the amount (def. 0)
- Returns:
- the object
- - (DIntArray *) size :(unsigned long) size
- Insure the size for the array
- Parameters:
- size - the requested size (in elements) for the array
- Returns:
- the object
- DTextable protocol methods
- - (DText *) toText
- Convert the object to a text string
- Returns:
- a (new) text string object
- DParsable protocol methods
- - (int) fromString :(char **) cstr
- Parse a string for an array of integers: ,;
- Parameters:
- cstr - the string to be parsed (moved to the first non-parsable character)
- Returns:
- the result (0, ERANGE, ENODATA)
- Array setters
- - (DIntArray *) clear
- Clear the array
- Returns:
- the object
- - (DIntArray *) set :(const int *) ints :(unsigned long) length
- Set an array of integers in the object
- Parameters:
- ints - the integers
length - the length of the integers
- Returns:
- the object
- Element methods
- - (DIntArray *) delete :(long) index
- Delete the integer at the given index
- Parameters:
- index - the index
- Returns:
- the object
- - (int) get :(long) index
- Get the integer at the given index
- Parameters:
- index - the index
- Returns:
- the integer from the array
- - (DIntArray *) insert :(long) index :(int) value
- Insert an integer at the given index
- Parameters:
- index - the index
value - the value to be inserted
- Returns:
- the object
- - (DIntArray *) put :(long) index :(int) element
- Put an integer at the given index
- Parameters:
- index - the index (-length..+length)
element - the integer to be placed
- Returns:
- the object
- Slice methods
- - (DIntArray *) delete :(long) from :(long) to
- Delete a range in the array
- Parameters:
- from - the start index
to - the end index (to >= from)
- Returns:
- the object
- - (DIntArray *) get :(long) from :(long) to
- Return a sub array
- Parameters:
- from - the start index
to - the end index (to >= from)
- Returns:
- a (new) integer array object
- - (DIntArray *) insert :(long) from :(long) to :(const int *) ints :(unsigned long) length
- Insert an array of integers in a part of the array in the object
- Parameters:
- from - the start index
to - the end index (to >= (from-1))
ints - the array with integers to be inserted
length - the length of the integers
- Returns:
- the object
- Array manipulation methods
- - (DIntArray *) append :(const int *) ints :(unsigned long) length
- Append an array to the object
- Parameters:
- ints - the integers to be appended
length - the length of the integer array
- Returns:
- the object
- - (DIntArray *) prepend :(const int *) ints :(unsigned long) length
- Prepend an array in front of the object
- Parameters:
- ints - the integers to be prepended
length - the length of the integer array to be prepended
- Returns:
- the object
- Stack methods
- - (int) pop
- Pop one integer from the end of the array
- Returns:
- the integer that is pulled (or 0 for empty stack)
- - (DIntArray *) push :(int) value
- Push one integer at the end of the array
- Parameters:
- value - the integer that is placed at the end
- Returns:
- the object
- - (int) tos
- Return the integer at the end of the array
- Returns:
- the integer (or 0 for empty stack)
- Queue methods (FIFO)
- - (int) dequeue
- Get the integer at the end of the array
- Returns:
- the integer (or 0 for empty queue)
- - (BOOL) enqueue :(int) value
- Put an integer at the start of the array
- Parameters:
- value - the integer
- Returns:
- success
- Comparable protocol methods
- - (int) compare :(DIntArray *) other
- Compare the integer array object with another integer array object
- Parameters:
- other - the object that should be compared (!= nil)
- Returns:
- the compare result (-1, 0, 1)
- Comparison methods
- - (int) bcompare :(const int *) ints :(unsigned long) length
- Compare the object with another array of integers
- Parameters:
- ints - the array of integers
length - the length of the array
- Returns:
- the compare result (-1, 0, 1)
- Statistical methods
- - (double) average :(long) from :(long) to
- Calculate the average in a range of the integer array
- Parameters:
- from - the start index
to - the end index (to >= from)
- Returns:
- the average (or 0.0)
- - (unsigned long) count :(int) search :(long) from :(long) to
- Count the number of occurrences of an integer in the array
- Parameters:
- search - the value that should be counted
from - the start index
to - the end index (to >= from)
- Returns:
- the number of occurrences
- - (long) index :(int) search :(long) from :(long) to
- Return the first index where the search integer is found
- Parameters:
- search - the integer that should be searched
from - the start index
to - the end index (to >= from)
- Returns:
- the first index or -1 = not found
- - (DIntArray *) invert :(long) from :(long) to
- Invert a range in the integer array
- Parameters:
- from - the start index
to - the end index (to >= from)
- Returns:
- the object
- - (int) max :(long) from :(long) to
- Determine the maximum integer in a range of the integer array
- Parameters:
- from - the start index
to - the end index (to >= from)
- Returns:
- the maximum integer
- - (int) min :(long) from :(long) to
- Determine the minimum integer in a range of the integer array
- Parameters:
- from - the start index
to - the end index (to >= from)
- Returns:
- the minimum integer
- - (long) rindex :(int) search :(long) from :(long) to
- Return the last index where the search integer is found
- Parameters:
- search - the integer that should be searched
from - the start index
to - the end index (to >= from)
- Returns:
- the last index or -1 = not found
- - (DIntArray *) sort :(long) from :(long) to
- Sort a range in the the integer array
- Parameters:
- from - the start index
to - the end index (to > from)
- Returns:
- the object
- - (double) standardDeviation :(long) from :(long) to
- Calculate the standard deviation in a range of the integer array
- Parameters:
- from - the start index
to - the end index (to >= from)
- Returns:
- the standard deviation
- - (long) sum :(long) from :(long) to
- Calculate the sum in a range of the integer array
- Parameters:
- from - the start index
to - the end index (to >= from)
- Returns:
- the sum of the integers
- - (double) variance :(long) from :(long) to
- Calculate the variance in a range of the integer array
- Parameters:
- from - the start index
to - the end index (to >= from)
- Returns:
- the variance
generated 05-Nov-2007 by ObjcDoc 3.0.0