next up previous contents index
Next: Dictionary Arrays ( d_array Up: Dictionaries Previous: Sorted Sequences ( sortseq

     
Sorted Sequences with Implementation Parameter ( _sortseq )

Definition

An instance of type _sortseq<K,I,impl> is a sorted sequence implemented by data type impl. impl must be one of the sorted sequence implementations listed in section Implementations Dictionaries or a user defined data structure fulfilling the specification given in section User Implementations Sorted Sequences. Note that the key type K must be linearly ordered.

#include < LEDA/ _sortseq.h >

Example

Using a sorted sequence implemented by skiplists to list all elements in a sequence of strings lying lexicographically between two given search strings.

#include <LEDA/_sortseq.h>
#include <LEDA/impl/skiplist.h>

main()
{ 
 _sortseq<string,int,skiplist> S;
 string s1,s2;

 while ( cin >> s1 &&  s1 != "stop" )  S.insert(s1,0);

 while ( cin >> s1 >> s2 )
 { seq_item start = S.locate(s1);
   seq_item stop  = S.locate(s2);
   for (seq_item it = start; it != stop; it = S.succ(it))
      cout << S.key(it) << endl; 
  }

}



LEDA research project
1999-04-23