New Version of SkipList Library Released
Friday, January 7, 2011 8:52:27 PM
http://sourceforge.net/projects/csskiplist/
New features in this release are some new containers. Yeah, there's a astounding amount of containers now. But they're all related. It's basically just selecting what options you want.
- Multi or Unique (Duplicates allowed or not)
- Auto or not (Auto means that you can use random access in logn time)
- Set, Map or Access (Access is where the key is within the element itself).
- Single or Double linked list.
So 2*2*3*2 = 24 containers. As you can see, you just pick the options you want and that decides what container to use. There are also the Indexed type skip lists that operate much like a vector, but in logarithmic time.
The new containers are Access type containers where you can have the key inside the element itself. This means you don't have to create a dummy element as you would normally. Or alternatively, you don't need to duplicate the key thus saving memory.
The Access containers are also available as delegate containers for the composite list where elements can be ordered in many different ways. This is actually the only way to have a key within a delegate container.
struct A
{
int ID;
int x,y;
A(int ID, int x, int y) : ID(ID), x(x), y(y) {}
};
struct GetID
{
int operator()(const A &a) const {return ID;}
};
AutoAccessSkipList<int,A,GetID> mylist;
void func()
{
mylist.insert(A(10,10,20));
mylist.insert(A(20,20,20));
mylist.insert(A(30,30,50));
AutoAccessSkipList<int,A,GetID>::iterator i = mylist.find(20); // Find item with ID = 20.
mylist[2].x = 50; // Change element at index 2 (third element).
mylist(10).y = 50; // Change element with ID = 10.
}
If the key type isn't an unsigned int, you can use mylist[key] as well.
I also changed a few methods. remove() in Indexed type skiplists has been changed to erase_value(). And remove_if() has been changed to erase_if(). destroy_if() has also been added.

