Collection Extensions

Previous Page TOC Index Next Page See Page

Mindy Compiler Mindy Debugger Mindy Object Extensions Streams Library Standard IO Print Library Format Library Melange Interface TK Library Collection extensions Table Extensions String extensions Regular Expressions Transcendental Library Time Library Random Library Matrix Library


The Collection extensions Library

Designed by the Gwydion Project

Copyright (c) 1994, 1995, 1996 Carnegie Mellon University All rights reserved.

1. Introduction

The various modules in this library contain a few new types and operations which are compatible with the collection types specified in the Dylan Reference Manual, but which are not part of that specification.

It is to be expected that more collection types will appear in time, and they will likely be added to this library. This may also result in reorganizations which could force incompatible changes to the existing modules. We hope to minimize such imcompatibilities and, when forced to them, will include sufficient information to facilitate conversion of existing code.

Collection-extensions exports these modules:

self-organizing-list
subseq
vector-search

2. The Self-Organizing-List Module

The "Self Organizing List" is a poor man’s hash table. More precisely, <self-organizing-list> is a subclass of <mutable-explicit-key-collection> and <stretchy-collection> for which addition and retrieval are both linear in the worst case, but which use a probabilistic strategy which yields nearly constant time in the best case.

Because they have a very low overhead, self-organizing lists may provide better peformance than hash tables in cases where references have a high degree of temporal locality. They may also be useful in situations where it is difficult to create a proper hash function.

Instantiate <self-organizing-list>s with

            make(<self-organizing-list>, test: test)

Test is expected to be an equality function. In particular, it is expected to satisfy the identity and transitivity requirements as described in the DRM. If not specified, test defaults to \==.

3. The Subsequence Module

<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:

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:

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

would produce a subsequence identical to the one produced by

            subsequence(source, start: 3)

4. The Vector-Search Module

The vector-search module provides basic search and replace capabilities upon restricted subsets of <sequence> -- primarily <vector>. Exploiting the known properties of these types yields substantially better performance than can be achieved for sequences in general.

The following functions are supplied:

find-first-key(vector, predicate?, #key start, end, failure) => key [Function]

find-last-key(vector, predicate?, #key start, end, failure) => key [Function]

Mindy Compiler Mindy Debugger Mindy Object Extensions Streams Library Standard IO Print Library Format Library Melange Interface TK Library Collection extensions Table Extensions String extensions Regular Expressions Transcendental Library Time Library Random Library Matrix Library

Previous Page TOC Index Next Page See Page

Copyright 1994, 1995, 1996, 1997 Carnegie Mellon University. All rights reserved.

Send comments and bug reports to gwydion-bugs@cs.cmu.edu