Well, Vector and Array are random access data structures, i.e., you can use indices. And Set is not random access; pretty much as the error message says.
These different data structures exist because they help make several kinds of functions fast: While vector and Array allow to access an element at a given position in constant time, e.g., Set allows to decide if a given element is contained in logarithmic time. Sets are implemented as a certain type of balanced binary tree type (AVL trees).
You can always convert back and forth between these data structures:
Code: Select all
polytope > $a=new Set<Int>(0,1,2,3);
polytope > $b=new Vector<Int>($a);
polytope > print $a->[2];
polymake: ERROR: No random access
polytope > print $b->[2];
2
A Set object is always ordered. You can access the first and the last element in constant time.
Code: Select all
polytope > print $a->front();
0
polytope > print $a->back();
3
But these are the only ones.