.TH "idarray" 3 "Mar 12, 2023"
.SH IdArray
.PP
.B
Inherits from:
Array
.SH Class Description
.PP
.B
IdArray
instances are used to hold objects (
.B
nil
is allowed)\&. This class is somewhat similar to
.B
String
, the difference being that a String is an Array of bytes, while this class provides a somewhat similar API to
.I
strings of id
\&.
.PP
.B
Note:
This class is present mostly for compatibility with ICpak101\&. You most likely want to use
.B
OrdCltn
instead of this class\&.
.PP
The method
.B
size
returns the number of non-nil objects in the
.B
IdArray
\&. The method
.B
capacity
returns the total number of objects that the array can hold\&.
.SH Method types
.PP
.B
Creation
.RS 3
.br
* new
.br
* new:
.br
* with:
.br
* copy
.br
* deepCopy
.br
* free
.RE
.PP
.B
Interrogation
.RS 3
.br
* size
.br
* at:
.br
* at:put:
.RE
.PP
.B
Resizing
.RS 3
.br
* capacity
.br
* capacity:
.br
* packContents
.RE
.PP
.B
Printing
.RS 3
.br
* printOn:
.RE
.PP
.B
Archiving
.RS 3
.br
* fileOutOn:
.br
* fileInFrom:
.RE
.SH Methods
.PP
new
.RS 1
+
.B
new
.RE
.PP
Creates an instance whose value is set to the empty array\&.
.PP
new:
.RS 1
+
.B
new
:(unsigned)
.I
n
.RE
.PP
Creates an instance of
.I
n
.B
nil
objects\&.
.PP
with:
.RS 1
+
.B
with
:(int)
.I
nArgs,\&.\&.\&.
.RE
.PP
Creates an instance of
.I
nArgs
objects, using a variable number of arguments, that may contain
.B
nil
objects\&.
.RS 3
id myArray = [IdArray with:3,nil,[Object new],nil];
.br
.RE
.PP
copy
.RS 1
-
.B
copy
.RE
.PP
Returns a copy of the receiver with its internal C array copied as well (but not the objects that it contains)\&.
.PP
deepCopy
.RS 1
-
.B
deepCopy
.RE
.PP
Like
.B
copy
, but also sends
.B
deepCopy
messages to the objects in the IdArray\&.
.PP
free
.RS 1
-
.B
free
.RE
.PP
Frees the receiver and its internal C array as well\&.
.PP
size
.RS 1
- (
unsigned
)
.B
size
.RE
.PP
Returns the number of non-nil objects in the array\&.
.PP
.B
Note:
For Stepstone compatibility (with ICpak101) this method is, for this class, not the same as
.B
capacity
\&. In the case of the
.B
IntArray
class,
.B
size
and
.B
capacity
are the same\&.
.PP
at:
.RS 1
-
.B
at
:(unsigned)
.I
anOffset
.RE
.PP
Returns the object at
.I
anOffset
or signals the
.B
OutOfBounds
exception if
.I
anOffset
is greater than the length of the array\&.
.PP
Unlike for
.B
OrdCltn
instances, this method may return a nil object\&.
.PP
at:put:
.RS 1
-
.B
at
:(unsigned)
.I
anOffset
.B
put
:
.I
anObject
.RE
.PP
Replaces the object at
.I
anOffset
with
.I
anObject
and returns the old object which was in that location\&. Generates an out of bounds exception if
.I
anOffset
is greater than the length of the array\&.
.PP
Unlike for
.B
OrdCltn
instances, this method will accept a nil object\&.
.PP
capacity
.RS 1
- (
unsigned
)
.B
capacity
.RE
.PP
Returns the total number of objects in the IdArray\&. (nil or non-nil)\&.
.PP
capacity:
.RS 1
-
.B
capacity
:(unsigned)
.I
nSlots
.RE
.PP
Changes the capacity to
.I
nSlots
\&. If
.I
nSlots
is larger than the current capacity, the memory added at the end will be zero-filled\&. If
.I
nSlots
is less than the current capacity, the array is truncated\&.
.PP
packContents
.RS 1
-
.B
packContents
.RE
.PP
Removes nil objects while preserving the order of elements in the
.B
IdArray
\&. Used to eliminate the \&'hole\&' left by a
.B
at:put:
message with a
.B
nil
argument\&.
.PP
printOn:
.RS 1
-
.B
printOn
:(IOD)
.I
aFile
.RE
.PP
Prints the array to
.I
aFile
without appending a newline\&. Returns the receiver\&.
.PP
fileOutOn:
.RS 1
-
.B
fileOutOn
:
.I
aFiler
.RE
.PP
Writes the array on
.I
aFiler
\&. Returns the receiver\&.
.PP
fileInFrom:
.RS 1
-
.B
fileInFrom
:
.I
aFiler
.RE
.PP
Reads a array object from
.I
aFiler
\&. Returns the receiver\&.