11 The Built-In Classes
An overview of collections is given in Chapter 8, "Collections."
<object>
<collection>
is the root class of the collection class hierarchy. It provides a set of basic operations on all collections.
The element type of <collection>
is indefinite < <object>
.
Function | Description | Page | |
---|---|---|---|
= | Compares two objects for equality. | 254 | |
empty? | Returns true if its argument is empty. | 279 | |
size | Returns the size of its argument. | 279 | |
shallow-copy | Returns a copy of its argument. | 277 |
Function | Description | Page | |
---|---|---|---|
limited | Returns a limited subtype of a class. | 249 |
<collection>
This class is disjoint from <sequence>
because key-test
is inert over the domain <sequence>
.
The element type of <explicit-key-collection>
is indefinite < <object>
.
Function | Description | Page | |
---|---|---|---|
limited | Returns a limited subtype of a class. | 249 |
<collection>
Sequences must be stable under iteration, and the iteration order must match the order of keys. Thus, the key associated with a sequence's iteration state can be determined by keeping a counter in parallel with the iteration state.
The default methods for add, add-new, remove, choose, choose-by, intersection, union, remove-duplicates, copy-sequence, concatenate, reverse, and sort all return new sequences that are instances of the type-for-copy of their primary sequence argument. However, more specialized methods are permitted to choose a more appropriate result class; for example, copy-sequence of a range returns another range, even though the type-for-copy value of a range is the <list> class.
<sequence>
is disjoint from <explicit-key-collection>
because of the inert domain over the function key-test
for <sequence>
.
The element type of <sequence>
is indefinite < <object>
.
Function | Description | Page | |
---|---|---|---|
concatenate | Returns the concatenation of one or more sequences in a sequence of a type determined by the type-for-copy of its first argument. | 309 | |
concatenate-as | Returns the concatenation of one or more sequences in a sequence of a specified type. | 310 | |
first | Returns the first element of a sequence. | 288 | |
second | Returns the second element of a sequence. | 288 | |
third | Returns the third element of a sequence. | 289 |
Function | Description | Page | |
---|---|---|---|
= | Compares two objects for equality. | 254 | |
key-test | Returns the function used by its collection argument to compare keys. | 283 |
Function | Description | Page | |
---|---|---|---|
limited | Returns a limited subtype of a class. | 249 |
<collection>
Every mutable collection is required to allow modification by implementing element-setter.
The element type of <mutable-collection>
is indefinite < <object>
.
Function | Description | Page | |
---|---|---|---|
map-into | Iterates over one or more collections and collects the results in an existing mutable collection. | 315 |
Function | Description | Page | |
---|---|---|---|
last-setter | Sets the last element of a mutable sequence. | 291 |
Function | Description | Page | |
---|---|---|---|
type-for-copy | Returns an appropriate type for creating mutable copies of its argument. | 277 |
Function | Description | Page | |
---|---|---|---|
limited | Returns a limited subtype of a class. | 249 |
<explicit-key-collection> <mutable-collection>
The element type of <mutable-explicit-key-collection>
is indefinite < <object>
.
Function | Description | Page | |
---|---|---|---|
limited | Returns a limited subtype of a class. | 249 |
<sequence> <mutable-collection>
The element type of <mutable-sequence>
is indefinite < <object>
.
<mutable-sequence>
:
Function | Description | Page | |
---|---|---|---|
first-setter | Sets the first element of a mutable sequence. | 289 | |
second-setter | Sets the second element of a mutable sequence. | 290 | |
third-setter | Sets the third element of a mutable sequence. | 290 |
Function | Description | Page | |
---|---|---|---|
first-setter | Sets the first element of a mutable sequence. | 289 | |
second-setter | Sets the second element of a mutable sequence. | 290 | |
third-setter | Sets the third element of a mutable sequence. | 290 |
Function | Description | Page | |
---|---|---|---|
limited | Returns a limited subtype of a class. | 249 |
<collection>
Stretchy collections allow element-setter to be called with a key that is not present in the collection, expanding the collection as necessary to add a new element in that case. Each concrete subclass of <stretchy-collection> must provide or inherit a method for element-setter that behaves as follows when there is not already an element present for the indicated key:
The element type of <stretchy-collection>
is indefinite < <object>
.
<stretchy-collection>
:
Function | Description | Page | |
---|---|---|---|
limited | Returns a limited subtype of a class. | 249 |
<mutable-sequence>
<array>
.
<sequence>
with elements that are instances of <integer>
. This argument specifies the dimensions of the array. The size of the sequence specifies the rank (number of dimensions) of the array, and each integer in the sequence specifies the size of a dimension. This argument is required.
<object>
specifying an initial value for each element of the array. The default value is #f
.
An array element is referred to by a (possibly empty) series of indices. The length of the series must equal the rank of the array. Each index must be a non-negative integer less than the corresponding dimension. An array element may alternatively be referred to by an integer, which is interpreted as a row-major index.
Arrays typically use space efficient representations, and the average time required to access a randomly chosen element is typically sublinear to the number of elements.
Whe a multi-dimensional array is created, the concrete class that is actually instantiated cannot be any of the specified subclasses of <array>
, which are all one-dimensional. Every implementation must have one or more concrete subclasses of <array>
that are used for this purpose. These concrete subclasses have no specified names, and their names are not exported by the Dylan module.
When a single-dimensional array is created, the array created will be an instance of <vector>
.
Each concrete subclass of <array>
must either provide or inherit implementations of the functions element
, element-setter
, and dimensions
.
The element type of <array>
is indefinite < <object>
.
Function | Description | Page | |
---|---|---|---|
rank | Returns the number of dimensions of an array. | 281 | |
row-major-index | Returns the row-major-index position of an array element. | 282 | |
aref | Returns the array element indicated by a set of indices. | 287 | |
aref-setter | Sets the array element indicated by a set of indices. | 287 | |
dimensions | Returns the dimensions of an array. | 282 | |
dimension | Returns the size of a specified dimension of an array. | 283 |
Function | Description | Page | |
---|---|---|---|
size | Returns the size of its argument. | 279 | |
rank | Returns the number of dimensions of an array. | 281 | |
row-major-index | Returns the row-major-index position of an array element. | 282 | |
aref | Returns the array element indicated by a set of indices. | 287 | |
aref-setter | Sets the array element indicated by a set of indices. | 287 | |
dimension | Returns the size of a specified dimension of an array. | 283 |
Function | Description | Page | |
---|---|---|---|
make | Returns a general instance of its first argument. | 244 | |
limited | Returns a limited subtype of a class. | 249 |
<array>
<vector>
.
<integer>
specifying the size of the vector.
<object>
specifying an initial value for each element of the vector. The default value is #f
.
<vector> has no direct instances; calling make on <vector> returns an instance of <simple-object-vector>.
Each concrete subclass of <vector> must either provide or inherit an implementation of size that shadows the method provided by <array>.
The element type of <vector>
is indefinite < <object>
.
Function | Description | Page | |
---|---|---|---|
vector | Creates and returns a freshly allocated vector. | 252 |
Function | Description | Page | |
---|---|---|---|
dimensions | Returns the dimensions of an array. | 282 | |
element | Returns the collection element associated with a particular key. | 284 |
Function | Description | Page | |
---|---|---|---|
make | Returns a general instance of its first argument. | 244 | |
limited | Returns a limited subtype of a class. | 249 |
<vector>
which provides an efficient implementation of fixed-length vectors.
<vector>
<simple-vector>
.
<integer>
specifying the size of the vector.
<object>
specifying an initial value for each element of the vector. The default value is #f
.
The class <simple-vector> provides a constant time implementation for the element and element-setter functions. This property is shared by all subtypes of <simple-vector>
.
Calling make
on a <simple-vector>
returns an instance of <simple-object-vector>
. The size of a simple vector cannot be changed after the simple vector has been created.
Vector literals (created with the #[
...]
syntax) are general instances of <simple-vector>
.
The element type of <simple-vector>
is indefinite < <object>
.
The class <simple-object-vector>
and the type limited(<simple-vector>, of: <object>)
have exactly the same instances, but neither is a subtype of the other. The relationship between them is simply that the make
method for the type returns an instance of the class.
Function | Description | Page | |
---|---|---|---|
element | Returns the collection element associated with a particular key. | 284 | |
element-setter | Sets the collection element associated with a particular key. | 285 |
Function | Description | Page | |
---|---|---|---|
make | Returns a general instance of its first argument. | 244 | |
limited | Returns a limited subtype of a class. | 249 |
<simple-vector>
<integer>
specifying the size of the vector. The default value is 0
.
<object>
specifying the initial value for each element. The default value is #f
.
The element type of <simple-object-vector>
is <object>
.
<vector> <stretchy-collection>
<integer>
specifying the initial size of the stretchy vector. The default value is 0
.
<object>
specifying the initial value for each element. The default value is #f
.
Because <stretchy-vector>
is abstract and instantiable but has no specified subclasses, every implementation must provide one or more concrete subclass to instantiate. These concrete subclasses have no specified names, and their names are not exported by the Dylan module.
The element type of <simple-vector>
is indefinite < <object>
.
Function | Description | Page | |
---|---|---|---|
add! | Adds an element to a sequence. | 294 | |
remove! | Removes an element from a sequence. | 298 |
Function | Description | Page | |
---|---|---|---|
limited | Returns a limited subtype of a class. | 249 |
<mutable-sequence> <stretchy-collection>
<integer>
specifying the initial size of the deque. The default value is 0
.
<object>
specifying the initial value for each element. The default value is #f
.
Because <deque>
is abstract and instantiable but has no specified subclasses, every implementation must provide one or more concrete subclass to instantiate. These concrete subclasses have no specified names, and their names are not exported by the Dylan module.
The element type of <deque>
is indefinite < <object>
.
Function | Description | Page | |
---|---|---|---|
push | Adds an element to the front of a deque. | 300 | |
pop | Removes and returns the first element of a deque. | 300 | |
push-last | Adds an element to the end of a deque. | 300 | |
pop-last | Removes and returns an element from the end of a deque. | 301 |
Function | Description | Page | |
---|---|---|---|
add! | Adds an element to a sequence. | 294 | |
remove! | Removes an element from a sequence. | 298 |
Function | Description | Page | |
---|---|---|---|
limited | Returns a limited subtype of a class. | 249 |
<pair>
. The head of a list contains an element, and the tail of the list contains a pointer to the next pair in the list. The list ends when the tail of a pair contains something besides another pair.A proper list has a final pair with a tail containing the empty list.
An improper list does not have a final pair with a tail containing the empty list, either because the tail of its final pair is not the empty list, or because the list is circular and thus does not have a final pair. Except when their behavior on improper lists is documented explicitly, collection or sequence functions are not guaranteed to return an answer when an improper list is used as a collection or a sequence. At the implementation's option, these functions may return the correct result, signal a <type-error>, or (in the case of a circular list) fail to return.
When treated as a collection, the elements of a list are the heads of successive pairs in the list.
<mutable-sequence>
<list>
.
<integer>
specifying the size of the list. The default value is 0
.
<object>
specifying the initial value for each element. The default value is #f
.
The <list> class is partitioned into two concrete subclasses, <pair> and <empty-list>. Calling make on <list>
will return a linked list made from pairs and terminated with the empty list.
The element type of <list>
is <object>
.
Function | Description | Page | |
---|---|---|---|
list | Creates and returns a freshly allocated list. | 247 | |
pair | Creates and returns a freshly allocated pair. | 247 |
Function | Description | Page | |
---|---|---|---|
head | Returns the head of a list. | 292 | |
tail | Returns the tail of a list. | 292 |
Function | Description | Page | |
---|---|---|---|
size | Returns the size of its argument. | 279 | |
= | Compares two objects for equality. | 254 | |
add! | Adds an element to a sequence. | 294 | |
remove! | Removes an element from a sequence. | 298 |
Function | Description | Page | |
---|---|---|---|
make | Returns a general instance of its first argument. | 244 |
<list>
The element type of <pair>
is <object>
.
Function | Description | Page | |
---|---|---|---|
head-setter | Sets the head of a pair. | 293 | |
tail-setter | Sets the tail of a pair. | 293 |
<pair>
:
Function | Description | Page | |
---|---|---|---|
pair | Creates and returns a freshly allocated pair. | 247 |
<empty-list> [Sealed Instantiable Class]
<list>
The element type of <empty-list>
is <object>
.
<sequence>
<real>
specifying the first value in the range. The default value is 0
.
by:
<real>
specifying the step between consecutive elements of the range. The default value is 1
.
to:
<real>
specifying an inclusive bound for the range. If by:
is positive, the range will include numbers up to and including this value. If by:
is negative, the range will include numbers down to to and including this value.to:
cannot be specified with above:
or below:
.
above:
<real>
specifying an exclusive lower bound for the range. The range will only include numbers above this value, regardless of the sign of by:
.above:
cannot be specified with to:
or below:
.
<real>
specifying an exclusive upper bound for the range. The range will only include numbers below this value, regardless of the sign of by:
.below:
cannot be specified with to:
or above:
.
<integer>
specifying the size of the range.
<range>
is used for creating sequences of numbers. Ranges may be infinite in size, and may run from higher numbers to lower numbers.
Because <range>
in abstract and instantiable but has no specified subclasses, every implementation must provide one or more concrete subclass to instantiate. These concrete subclasses have no specified names, and their names are not exported by the Dylan module.
The element type of <range>
is indefinite < <real>
.
Function | Description | Page | |
---|---|---|---|
member? | Returns true if a collection contains a particular value. | 320 | |
size | Returns the size of its argument. | 279 | |
copy-sequence | Returns a freshly allocated copy of some subsequence of a sequence. | 309 | |
= | Compares two objects for equality. | 254 | |
reverse | Returns a sequence with elements in the reverse order of its argument sequence. | 301 | |
reverse! | Returns a sequence with elements in the reverse order of its argument sequence. | 301 | |
intersection | Returns the intersection of two sequences. | 305 | |
type-for-copy | Returns an appropriate type for creating mutable copies of its argument. | 277 |
Function | Description | Page | |
---|---|---|---|
limited | Returns a limited subtype of a class. | 249 |
<mutable-sequence>
<integer>
specifying the size of the string. The default value is 0
.
<character>
specifying the initial value for each element. The default value is ' ' (space).
<string>
is used for holding sequences of characters.<string> has no direct instances; calling make on <string> will return an instance of a concrete subclass of <string>.
The element type of <string>
is indefinite < <character>
.
Function | Description | Page | |
---|---|---|---|
< | Returns true if its first operand is less than its second operand. | 256 | |
as-lowercase | Coerces an object to lowercase. | 276 | |
as-lowercase! | Coerces an object to lowercase in place. | 276 | |
as-uppercase | Coerces an object to uppercase. | 275 | |
as-uppercase! | Coerces an object to uppercase in place. | 275 |
Function | Description | Page | |
---|---|---|---|
limited | Returns a limited subtype of a class. | 249 |
<string>
<vector>
<integer>
specifying the size of the byte string. The default value is 0
.
<character>
specifying the initial value for each element. The default value is ' ' (space).
element
and element-setter
methods.
The element type of <byte-string>
is indefinite < K2
(where K2 is a subtype of <character>
).
Function | Description | Page | |
---|---|---|---|
element | Returns the collection element associated with a particular key. | 284 | |
element-setter | Sets the collection element associated with a particular key. | 285 |
<string>
<vector>
<integer>
specifying the size of the unicode string. The default value is 0
.
<character>
specifying the initial value for each element. The default value is ' ' (space).
element
and element-setter
methods.
The element type of <unicode-string>
is indefinite < K1
(where K1 is a subtype of <character>
).
Function | Description | Page | |
---|---|---|---|
element | Returns the collection element associated with a particular key. | 284 | |
element-setter | Sets the collection element associated with a particular key. | 285 |
Tables are stretchy in that they allow the addition and removal of keys. <table> and its subclasses are the only predefined classes that are stretchy but are not stretchy sequences.
For a complete description of tables, see "Tables" on page 120.
<mutable-explicit-key-collection> <stretchy-collection>
<table>
is the only predefined instantiable subclass of <explicit-key-collection>
.Every concrete subclass of <table> must provide or inherit a method for table-protocol. For details, see "Tables" on page 120.
<table> has no direct instances; calling make on <table> will return an instance of <object-table>.
The element type of <table>
is indefinite < <object>
.
Function | Description | Page | |
---|---|---|---|
table-protocol | Returns functions used to implement the iteration protocol for a tables. | 327 |
Function | Description | Page | |
---|---|---|---|
forward-iteration-protocol | Returns a group of functions used to iterate over the elements of a collection. | 324 | |
table-protocol | Returns functions used to implement the iteration protocol for a tables. | 327 | |
remove-key! | Modifies an explicit key collection so it no longer has a particular key. | 322 | |
element | Returns the collection element associated with a particular key. | 284 | |
element-setter | Sets the collection element associated with a particular key. | 285 | |
size | Returns the size of its argument. | 279 | |
key-test | Returns the function used by its collection argument to compare keys. | 283 |
Function | Description | Page | |
---|---|---|---|
limited | Returns a limited subtype of a class. | 249 |
<table>
<object-table>
is abstract and instantiable but has no specified subclasses, every implementation must provide one or more concrete subclasses to instantiate. These concrete subclasses have no specified names, and their names are not exported by the Dylan module.
The element type of <object-table>
is indefinite < <object>
.
Function | Description | Page | |
---|---|---|---|
table-protocol | Returns functions used to implement the iteration protocol for a tables. | 327 |
Function | Description | Page | |
---|---|---|---|
limited | Returns a limited subtype of a class. | 249 |
Generated with Harlequin WebMaker