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