intarray Specification Sheet


Portable Object Compiler (c) 1998 by Stes & Lerman. All Rights Reserved.

IntArray

Inherits from:Array

Class Description

IntArray instances are used to hold regular, small, C integers (of type int). This class is somewhat similar to String, the difference being that a String is an Array of bytes, while this class provides a somewhat similar API to strings of int.

Method Types

Creation

Interrogation

Printing

Archiving

Methods



new

+ new

Creates an instance whose value is set to the empty array.



new:

+ new :(unsigned) n

Creates an instance of n zeroes.



with:

+ with :(unsigned) nArgs,...

Creates an instance of nArgs objects, using a variable number of int arguments.

id myArray = [IntArray with:3,0,1,2];


copy

- copy

Returns a copy of the receiver with its internal C array copied as well.

See also: - strCopy



deepCopy

- deepCopy

For this class, this method acts as copy.



free

- free

Frees the receiver and its internal C array as well.



size

- (unsigned) size

Returns the number of actual characters in the array, excluding the NULL terminator.



intAt:

- (int) intAt :(unsigned) anOffset

Returns the integer at anOffset or generates an error if anOffset is greater than the length of the C array.



intAt:put:

- (int) intAt :(unsigned) anOffset put :(int) anInt

Replaces the integer at anOffset with anInt and returns the old integer which was in that location. Generates an out of bounds exception if anOffset is greater than the length of the array.



printToFile:

- printToFile :(FILE *) aFile

Prints the array to aFile without appending a newline. Returns the receiver.



fileOutOn:

- fileOutOn : aFiler

Writes the array on aFiler. Returns the receiver.



fileInFrom:

- fileInFrom : aFiler

Reads a array object from aFiler. Returns the receiver.