Collection classes

JLib's collections are influenced by Java, the STL, and Smalltalk. There's some redundancy amoung the various classes

Smart Pointers

<JPtr.hpp> defines several template classes designed to be used as smart pointers. Smartness here indicates reference counting (in JPtr), object deletion (JPtr and auto_ptr), and helpful collection properties. This latter means that you can store a JPtr to an object in a collection and then use the value of the object (as opposed to the pointer) when considering ordering and equality. Thus you don't need a copy constructor, and collection use becomes more efficient.

Hashtables

A hashtable is a Fast Lookup Device.

JHashtable is defined in <JHashtbl.hpp>, standard things are provided.

If you require reentrancy, <JSafeHT.hpp> defines JSafeHTable.

<JMemoTbl.hpp> defines JMemoTable. This is a bit like a cache -- look at the header file for more information.

Sequence (Vector)

<JSeq.hpp> defines JSequence, which is just that, an ordered collection. Like a dynamic array. Or class Vector in Java. It's implemented with an array, so it's not terribly efficient at removing and inserting things.

Lists, Queues, Stacks

<JList.hpp> defines JList, which isn't terribly useful as is, JQueue, and JStack which often are. These are implemented using linked lists, so operations are cheap.

(Keyed or Sorted) Bags, Sets

<JSet.hpp> provides JSet, JSortedSet, and JKeySet. <JBag.hpp> does similar things for bags. These provide sorted or unsorted collections, with or without memeber equality being okay. You should use a keyset as opposed to a hashtable when you need some concept of enumeration order (or can't think of a decent hash function!).

These things all inherit from JCollection which is defined along with its friends of iterators & cursors in <JColln.hpp>.

These are implemented using as-noddy-as-you-like binary trees, so operations are efficient. Oh yes.

Note that `keyed' really means `key-sorted'.


John Fairhurst 11th June 1998