IndexSet.kl

Types

IndexSet (struct)

The IndexSet can be used to express a set of indices, where the index range is relatively contiguous. This can be useful to create a set of indices pointing to a larger array, for example. An IndexSet is particularly useful for efficiently removing duplicate indices, as it only allocates a few buffers as opposed to using a Dictionary.

/*
** Example: IndexSet
*/

require Containers;
  
operator entry() {

      IndexSet indexSet;
      indexSet.add(3);
      indexSet.add(9);
      indexSet.add(3);
      indexSet.add(4);
      indexSet.add(9);
      
      report("Contains '2': " + indexSet.has(2));
      report("Contains '3': " + indexSet.has(3));
      
      report("Indices:");
      for( Size i = 0; i < indexSet.size(); ++i )
        report( indexSet.get(i) );
  
}

/*
** Output:

Contains '2': false
Contains '3': true
Indices:
3
9
4

*/

Methods

  IndexSet ( in IndexSet other )
  IndexSet ()
  add ! ( in IndexSet other )
Boolean add ! ( in UInt32 index )
  clear ! ()
IndexSet clone ? ()
  free ! ()
UInt32 get ? ( in Size offset )
:ref:`UInt32 <uint32>`<> getIndices ? ()
Boolean has ? ( in UInt32 index )
Size potentialIndexRange ? ()
  removeAtOffset ! ( in UInt32 offset )
Size size ? ()