Implementation Challenges
Some of the functionality in C5 is difficult to implement efficientlythe combination of hash indexes and sublist views on linked lists, for instance.
First, it is fairly easy to provide each of these two extensions in isolation. A hash-indexed linked list in C5 is implemented by maintaining a hash dictionary that maps an item x to the list node in which it appears (if any). A sublist view is implemented as a pair of the list node just before the view and the list node just after the view, and all proper lists have an artificial sentinel node added before and after the list.
However, combining the two features is nontrivial because hash-based item lookup should work on sublist views too, and we want to share a single hash dictionary between all views of a list (or else view sliding would be extremely slow). So when performing hash-based item lookup on a view, we need to quickly decide whether the resulting item falls within the given view, not somewhere else in the underlying list. Traversing the view to see whether the item is within the view would be slow and would defeat the purpose of the hash index.
Instead, we adopt a list-ordering algorithm due to Sleator and Dietz in the version described by Bender (theory.lcs.mit.edu/ ~edemaine/papers/DietzSleator_ESA2002/ paper.pdf). The basic idea is to give each list node an integer tag so that nodes appear in a strictly increasing tag order. The Sleator-Dietz-Bender algorithm describes how to efficiently redistribute node tags at insertions so that a newly inserted node can be given a tag strictly between those of its neighbors. In the C5 implementation, we use a two-level version of this basic scheme, by maintaining tags on groups of nodes at the first level, and tagging the groups themselves at the second level.
Conclusion
Informal feedback from users has been very positive, showing that the C5 library provides useful, advanced and well-tested collection classes.