The Chain Package under DERVISH provides users with a generic container class. We use the word chain as a synonym for a linked list. We have chosen to use chain so as to:
A chain responds to the following operations:
Sequential operations on a chain using the index method are very fast since, subscribing to the locality of reference principle, the most recently accessed element is cached. Thus the entire chain is not traversed to get to the n+1 element after getting the n element.
Any operations on chains can be done using either method, however, the usefulness of the cursor method comes in play when the need arises to change the state of the chain during traversal (add/remove a new/existing element). Since a cursor contains state information of the chain being traversed, it can be used to grow or shrink the chain on demand. At present, a chain can have at most 10 simultaneously active curosrs.
Chain are 0-indexed beasts. Logically, they look like:
chain +-----+ | | +-------------------| |------------------+ | +-----+ | | | HEAD V V TAIL +-----+ +-----+ +-----+ +-----+ | |------->| |------->| |------->| |--> NULL NULL <--| |<-------| |<-------| |<-------| | +-----+ +-----+ +-----+ +-----+ (Index 0 1 2 3) Elements on the chain