The subseq Module

Overview

<subsequence> is a new subclass of <sequence>. A subsequence represents an aliased reference to some part of an existing sequence. Although they may be created by make (with required keywords source:, start: and end:) on one of the instantiable subclasses, they are more often created by calls of the form

subsequence(sequence, start: 0, end: 3)

where start: and end: are optional keywords which default to the beginning and end, respectively, of the source sequence. No other new operations are defined for subsequences, since all necessary operations are inherited from <sequence>.

Because subsequences are aliased references into other sequences, several properties must be remembered:

  1. The contents of a subsequence are undefined after any destructive operation upon the source sequence.

  2. Destructive operations upon subsequences may be reflected in the source. The results of reverse! and sort! should be expected to affect the source sequence for vector subsequences.

If the source sequences are instances of <vector> or <string>, then the implementation will use subclasses of <subsequence> which are also subclasses of <vector> or <string>.

Efficiency notes:

  1. The implementation tries to insure that subsequences of subsequences can be accessed as efficiently as the original subsequence. (For example, the result of

    subsequence(subsequence(source, start: 1), start: 2)
    

    would produce a subsequence identical to the one produced by

    subsequence(source, start: 3)
    
  2. Vector subsequences, like all other vectors, implement constant time element access.

  3. Non-vector subsequences may take non-constant time to create, but will provide constant-time access to the first element. This should produce the best performance provided some element of the subsequence is accessed at least once.

Reference

<byte-vector-subsequence> Class
Superclasses:

<vector-subsequence>

<subsequence> Abstract Class
Superclasses:

<sequence>

Init-Keywords:
  • end (required) – An instance of <integer>.

  • source (required) – An instance of <sequence>.

  • start (required) – An instance of <integer>.

subsequence Generic function
Signature:

subsequence (seq) => (#rest results)

Parameters:
Values:
  • #rest results – An instance of <object>.

subsequence(<subsequence>) Method
subsequence(<sequence>) Method
subsequence(<generic-subsequence>) Method
subsequence(<vector>) Method
subsequence(<byte-vector>) Method
subsequence(<byte-vector-subsequence>) Method
subsequence(<string>) Method