Copyright © 2003 Southern Storm Software, Pty Ltd.
Permission to distribute unmodified copies of this work is hereby granted.
The library was designed to have a similar "flavour" to the existing non-generic C# collections, with some ideas borrowed from the C++ Standard Template Library (STL), and the Java 2 Collections library.
ArrayList<T> are used to indicate
generic classes; whereas notations such as ArrayList are
used to indicate the traditional non-generic classes.
ArrayList's, but only synchronized
Hashtable's.IList.IList inside an
ArrayList, to get around the algorithm limitations.Queue class, but no
IQueue interface. So, it isn't easy to
replace an array based queue with a linked list based queue.virtual methods,
usually to allow read-only or type-safe wrapping. This can make
the base implementation less efficient, due to the overhead
of virtual method calls that will rarely point at anything
except the base implementation.IsReadOnly and IsFixedSize are common
collection traits like IsSynchronized, but appear
in subinterfaces instead of ICollection.
ReadOnlyList<T>.Algorithm
utility class as static generic methods.sealed. Modified functionality
is provided using decorators.ICollection<T>.AbstractCollection. This is typically used to
implement common utility methods (e.g. addAll() for copying
one collection into another). Such utility methods are placed into the
Algorithm class in our implementation.
An equivalent of the existing CollectionBase class is not
needed in this implementation. It is typically used to enforce type
safety constraints, which the generic language facilities are already
taking care of for us. CollectionBase is also used to
get notification of insertions, removals, etc. This can be accomplished
using decorator classes instead.
Notes: the design of iterators is based on the Java 2 collection classes. The idea of ejecting algorithms and utility methods out of the concrete classes is borrowed from the C++ Standard Template Library.
ICollection<T>IDeque<T>IDictionary<KeyT, ValueT>IIterable<T>IList<T>IsRandomAccess property can be used to determine
if the indexer implements constant-time lookups (e.g.
ArrayList<T>) or non constant-time lookups
(e.g. LinkedList<T>).IQueue<T>ISet<T>IStack<T>IIterator<T>IEnumerator
interface, with the addition of a Remove method.
This method is used to remove the current item in the iteration
in such a way that traversal can continue naturally.IListIterator<T>IIterator<T> with the ability to traverse
backwards through a list, to get the current position by index,
and to modify the current item in-place.IDictionaryIterator<T>IIterator<T> with properties that
extract the key and value components, and modify the value of
the current item in-place. There is no counterpart to the
IDictionary.Entry property, because it is identical
to Current.Current and calling
Remove on the iterator.
IComparable<T>IComparable
interface. Objects that implement this interface can be compared.
IComparer<T>IComparer
interface. It compares two values of type T.IHashCodeProvider<T>IHashCodeProvider
interface. It takes a value of type T and returns
a hash code, suitable for use in classes such as
Hashtable<T>.ICapacityArrayList<T>
that use an array to implement growable data structures.ArrayList<T>IList<T>, organised
as an array.ArrayQueue<T>IQueue<T>, organised
as an array.ArrayStack<T>IStack<T>, organised
as an array.Hashtable<KeyT, ValueT>IDictionary<KeyT, ValueT>,
organised as a hash.LinkedList<T>IList<T>, organised
as a doubly-linked list. This class also implements
IDeque<T>, IQueue<T>,
and IStack<T>.ListSet<T>ISet<T> on top of
an underlying IList<T> object. By default,
a LinkedList<T> object is used.SinglyLinkedList<T>IList<T>, organised
as a singly-linked list. This class also implements
IQueue<T> and IStack<T>.TreeSet<T>ISet<T> as a
balanced binary tree.TreeDictionary<KeyT, ValueT>IDictionary<KeyT, ValueT>
as a balanced binary tree.FixedSizeCollection<T>InvalidOperationException.ReadOnlyCollection<T>InvalidOperationException.SynchronizedCollection<T>
CollectionAdapter<T>ICollection<T>
and exports the non-generic ICollection interface.CollectionWrapper<T>ICollection and
exports the generic ICollection<T> interface.ComparableAdapter<T>IComparable<T>
and exports the non-generic IComparable interface.ComparableWrapper<T>IComparable and
exports the generic IComparable<T> interface.ComparerAdapter<T>IComparer<T>
and exports the non-generic IComparer interface.ComparerWrapper<T>IComparer and
exports the generic IComparer<T> interface.DictionaryAdapter<KeyT, ValueT>IDictionary<KeyT, ValueT>
and exports the non-generic IDictionary interface.DictionaryWrapper<KeyT, ValueT>IDictionary and
exports the generic IDictionary<KeyT, ValueT>
interface.DictionaryEnumeratorAdapter<KeyT, ValueT>IDictionaryIterator<KeyT, ValueT>
and exports the non-generic IDictionaryEnumerator
interface.DictionaryEnumeratorWrapper<KeyT, ValueT>IDictionaryEnumerator and
exports the generic
IDictionaryIterator<KeyT, ValueT> interface.EnumerableAdapter<T>IIterable<T>
and exports the non-generic IEnumerable interface.EnumerableWrapper<T>IEnumerable and
exports the generic IIterable<T> interface.EnumeratorAdapter<T>IIterator<T>
and exports the non-generic IEnumerator interface.EnumeratorWrapper<T>IEnumerator and
exports the generic IIterator<T> interface.HashCodeProviderAdapter<T>IHashCodeProvider<T>
and exports the non-generic IHashCodeProvider
interface.HashCodeProviderWrapper<T>IHashCodeProvider and
exports the generic IHashCodeProvider<T>
interface.ListAdapter<T>IList<T>
and exports the non-generic IList interface.ListWrapper<T>IList and
exports the generic IList<T> interface.*Adapter" classes to wrap generic
collections for non-generic use, and use "*Wrapper" classes
to wrap non-generic collections for generic use.
AlgorithmBuiltinComparer<T>IComparer<T> which uses
the builtin "<" and ">" operators
to perform the comparison. This is only useful when T
is a primitive numeric type.Comparer<T>IComparer<T> which uses
IComparable<T> and IComparable
to perform the comparison.Complex<T>T.DictionaryEntry<KeyT, ValueT>Predicate<T>T
and returns true if some predicate condition
has been satisfied by the argument.RangeList<T>IList<T> to access a sub-range.ReverseIterator<T>IListIterator<T> to reverse
the direction of traversal.TreeBase<KeyT, ValueT>TreeSet<KeyT> and
TreeDictionary<KeyT, ValueT>. Not recommended
for direct use by programmers.