The Instantiable Collection Classes
Dylan provides several standard instantiable collection classes, in addition to classes the user might wish to add. Each provides unique capabilities, strengths, and weaknesses.
<array> [Abstract Instantiable Class]
Arrays are structures whose elements are arranged according to a Cartesian coordinate system. 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 in the number of elements.
make of <array> supports the keywords dimensions: and fill:. dimensions: is required and must be a sequence of non-negative integers. fill: (default #f) specifies the initial value to be placed in all elements of the array.
Each concrete subclass of <array> must either provide or inherit implementations of the functions element and element-setter.
<byte-string> [Sealed Instantiable Class]
This sealed subclass of <vector> provides efficient storage for elements that are eight-bit characters. It also inherits lexicographic ordering from the <string> class. make of <byte-string> supports the keywords size: and fill:. size: (default 0) tells how large a <byte-string> to create; fill: specifies the initial value of every element.
<deque> [Instantiable Class]
This subclass of <mutable-sequence> implements double-ended queues. make of <deque> supports the keywords size: and fill:. size: (default 0) tells how large a <deque> to create; fill: (default #f) specifies the initial value of every element.
<list> [Sealed Instantiable Class]
This sealed subclass of <sequence> provides efficient support for linked lists. make of <list> supports the keywords size: and fill:. size: (default 0) tells how large a <list> to create; fill: (default #f) specifies the initial value of every element.
<empty-list> [Sealed Instantiable Class]
The class <empty-list> has only one instance, the empty list. The empty list is a direct instance of <empty-list> and an indirect instance of <list>. Note that <empty-list> is not == to singleton (#()).
? object-class (#()) <empty-list> ? define method f (x :: <empty-list>) 1 end; ? define method f (x == #()) 2 end; ? define method f (x :: <list>) 3 end; ? f (#()) 2 ? f (#("chocolate", "vanilla")) 3
<range> [Instantiable Class]
A subclass of <sequence> that represents arithmetic sequences. Some ranges can be infinitely large. The permitted initargs are from:, to:, above:, below:, by:, and size:. from: (default 0) is the first value in the range. by: (default 1) is the step between consecutive elements of the range. size: specifies the size of the range. range: has three additional initargs, to:, above: and below:, which constrain the range. to: is an inclusive bound, above: is an exclusive lower bound and below is an exclusive upper bound. above: and below: constrain the range independent of the sign of by:. It is permissible to specify a range that runs from a higher to a lower value by specifying a negative value for by:.
<simple-object-vector> [Sealed Instantiable Class]
This sealed subclass of <vector> supports elements of any class. make of <simple-object-vector> supports the keywords size: and fill:. size: (default 0) specifies the size of the <simple-object-vector>; fill: (default #f) specifies the initial value of every element.
<stretchy-vector> [Abstract Instantiable Class]
This subclass of <vector> supports elements of any class. make of <stretchy-vector> supports the keywords size:, fill:. size: (default 0) tells how large a <stretchy-vector> to create; fill: (default #f) specifies the initial value of every element.
<string> [Abstract Instantiable Class]
A subclass of <sequence> whose elements are all characters. <string> supports lexicographic comparison. <string> has no direct instances; calling make on <string> will return an instance of a concrete subclass of <string>. make of <string> supports the init-keywords size: and fill:. size: (default 0) tells how large a string to create.
<table> [Abstract Instantiable Class]
Also called a hashtable, a table is an unordered mapping between arbitrary keys and elements. Tables are the only predefined collections that are unstable under iteration. make of <table> supports the init-keyword size:. When specified, it provides a hint to the implementation of the class as to the expected number of elements to be stored in the table, which might be used to control how much space to initially allocate for the table. The default value is unspecified.The class <table> provides an implementation of the Iteration Protocol, using the function table-protocol. Every concrete subclass of <table> must provide or inherit a method for table-protocol. See the Table Protocol section for details.
<table> has no direct instances; calling make on <table> will return an instance of <object-table>.
<object-table> [Sealed Instantiable Class]
A subclass of <table> that compares keys using ==.
<unicode-string> [Sealed Instantiable Class]
This sealed subclass of <vector> provides efficient storage for elements that are sixteen-bit Unicode characters. It inherits lexicographic ordering from the <string> class. make of <unicode-string> supports the keywords size: and fill:. size: (default 0) tells how large a <unicode-string> to create; fill: (default ' ') specifies the initial value of every element.
<vector> [Abstract Instantiable Class]
The subclass of <array> whose instances are of rank one (i.e. have exactly one dimension). All one-dimensional arrays are vectors.Next section: Operations on Arrays<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>.