ATerm++

PrevUpHomeNext

Class indexed_set

genspect::indexed_set —

Synopsis

class indexed_set {
public:
  // construct/copy/destruct
  indexed_set(unsigned int, unsigned int);
  ~indexed_set();

  // public member functions
  void reset();
  std::pair< long, bool > put(aterm);
  long index(aterm);
  aterm get(long);
  void remove(aterm);
  aterm_list elements();
};

Description

indexed_set construct/copy/destruct

  1. indexed_set(unsigned int initial_size, unsigned int max_load_pct);

    Create a new indexed_set.

  2. ~indexed_set();

    This function releases all memory occupied by the indexed_set..

indexed_set public member functions

  1. void reset();

    Clear the hash table in the set. This function clears the hash table in the set, but does not release the memory. Using indexed_set_reset instead of indexed_set_destroy is preferable when indexed sets of approximately the same size are being used.

  2. std::pair< long, bool > put(aterm elem);

    Enter elem into the set. This functions enters elem into the set. If elem was already in the set the previously assigned index of elem is returned, and new is set to false. If elem did not yet occur in set a new number is assigned, and new is set to true. This number can either be the number of an element that has been removed, or, if such a number is not available, the lowest non used number is assigned to elem and returned. The lowest number that is used is 0.

  3. long index(aterm elem);

    Find the index of elem in set. The index assigned to elem is returned, except when elem is not in the set, in which case the return value is a negative number.

  4. aterm get(long index);

    Retrieve the element at index in set. This function must be invoked with a valid index and it returns the elem assigned to this index. If it is invoked with an invalid index, effects are not predictable.

  5. void remove(aterm elem);

    Remove elem from set. The elem is removed from the indexed set, and if a number was assigned to elem, it is freed to be reassigned to an element, that may be put into the set at some later instance.

  6. aterm_list elements();

    Retrieve all elements in set. A list with all valid elements stored in the indexed set is returned. The list is ordered from element with index 0 onwards.

Copyright © 2004 Wieger Wesselink

PrevUpHomeNext