Version 1.0, Copyright ©1995 by Paul S. McCarthy and Eric Sunshine. All Rights Reserved.
Paul S. McCarthy and Eric Sunshine -- October 1, 1995
| Inherits From:
| Object
|
|
| Declared In:
| MiscIntList.h
|
| An MiscIntList provides a simple interface to an array of integers. The class provides methods sorting the array as
well as general list maintenance. Methods are provided for conversion to and from a string representation of the
numbers contained in the list.
This class is used by MiscTableScroll as a means to communicate lists of integers with the client. The string
conversion methods provide a simple interface for generating data suitable for storage by the NeXT defaults system.
For instance, to store the user's column ordering preference in NeXT defaults, the client could ask MiscTableScroll to
fill an MiscIntList with the current ordering, convert that to a string representation, and then save it to NeXT defaults.
|
| array
| The storage for the list of integers.
|
| Initializing and freeing
| - init
- initFromString:
- free
- copyFromZone:
|
|
| Querying and emptying
| - count
- empty
|
|
| Manipulating by index
| - intAt:
- addInt:
- addIntList:
- insertInt:at:
- removeIntAt:
- replaceIntAt:with:
|
|
| Sorting
| - sort
- sortUsing:data:
|
|
| String conversions
| - readFromString:
- writeToString
- writeToString:size:
- writeToString:size:canExpand:
|
|
| Low-level access
| - rawData
|
| - (void)addInt:(int)value
|
| Appends value to the list. Equivalent to: -insertInt:value at:[self count].
See also: - addIntList:, - insertIntAt:, -removeIntAt:
addIntList:
|
| - (void)addIntList:(MiscIntList*)list
|
| Appends the contents of list to the end of the receiver.
See also: - addInt:
copyFromZone:
|
| - copyFromZone:(NXZone*)zone
|
| Allocates, initializes, and returns a copy of the receiver.
See also: - copy (Object)
count
|
| Returns the number of integers in the list.
empty
|
| Empties the list. Returns self.
See also: - free
free
|
| Frees the storage used by the list.
See also: - init, - empty
init
|
| Initializes the storage used by the list. This method is the designated initializer. Returns self.
See also: - initFromString:, - free
initFromString:
|
| - initFromString:(char const*)s
|
| - (void)insertInt:(int)value
|
| Inserts value at position pos in the list. The list is expanded if needed. Intervening slots are initialized to zero.
See also: - addInt:, - removeIntAt:, - replaceIntAt:with:
intAt:
|
| - (int)intAt:(unsigned int)pos
|
| Returns the integer at position pos or 0 if pos is out-of-range..
rawData
|
| Returns a pointer to the actual array of integers. This allows low-level, fast access to the data when one needs to avoid
the overhead of Objective-C messages. The array should not be modified.
readFromString:
|
| - (int)readFromString:(char const*)s
|
| - (void)removeIntAt:(unsigned int)pos
|
| Removes the integer at position pos from the list. Nothing happens if pos is beyond the end of the list.
See also: - addInt:, - insertInt:at:, - replaceIntAt:with:
replaceIntAt:with:
|
| - (void)replaceIntAt:(unsigned int)pos
|
| Replaces the integer at position pos with value. If pos is out-of-range then nothing is replaced.
See also: - addInt:, - insertInt:at:, - removeIntAt:
sort
|
| Sorts the list in ascending numeric order.
See also: - sortUsing:data:
sortUsing:data:
|
| - (void)sortUsing:(MiscIntListCompareFunc)cmp_func
|
| Sort the list of integers using the comparison function cmp_func. If cmp_func is NULL then the list is sorted in standard
ascending numeric order. The meaning of the data argument is unspecified and is determined by the comparision
function cmp_func to which it is passed unmolested.
MiscIntListCompareFunc is a typedef which takes as arguments the data variable plus two integers for comparision.
It should return a negative value if the first integer is less than the second, a positive value if the first integer is greater
than the second, or zero if the integers are equal.
|
typedef int (*MiscIntListCompareFunc)( void* userData, int x, int y );
| See also: - sort
writeToString
|
| Allocates a string using malloc() and writes a string representation of the contents of the list to it. It is the client's
responsibility to free() the returned string. Equivalent to: -writeToString:0 size:0 canExpand:YES. Returns the
newly allocated buffer.
See also: - readFromString:, - writeToString:size:, - writeToString:size:canExpand:
writeToString:size:
|
| - (char*)writeToString:(char*)buff
|
| Writes a string representation of the contents of the list to the buffer buff of size buff_size. Equivalent to:
-writeToString:buff size:buff_size canExpand:NO. Returns buff or 0 if buff_size wasn't large enough to hold
the string.
See also: - readFromString:, - writeToString, - writeToString:size:canExpand:
writeToString:size:canExpand:
|
| - (char*)writeToString:(char*)buff
|
| size:(int)buff_size
canExpand:(BOOL)flag
|
| Constants and Defined Types
|
typedef int (*MiscIntListCompareFunc)( void* userData, int x, int y );