Sset Struct Reference

Public interface for a Sset (Sorted Set) class. More...

#include <Sset.h>

Related Functions

(Note that these are not member functions.)



Sset_ptr Sset_copy (const Sset_ptr self)
 Creates a copy of the given set instance.
Sset_ptr Sset_copy_func (const Sset_ptr self, void *(*func)(void *, void *), void *arg)
 Creates a copy of the given set instance, copying each element by calling given function.
Sset_ptr Sset_create (void)
 Creates an instance of a Sorted Set.
Sset_ptr Sset_create_with_param (PFIVPVP compare)
 Creates an instance of a Sorted Set with a comparing function.
void * Sset_delete (Sset_ptr self, Sset_key key, boolean *is_found)
 Removes an element with key "key" from the set.
void Sset_delete_iter (Sset_ptr self, Ssiter iter)
 Removes an element pointed by the iterator.
void Sset_destroy (Sset_ptr self)
 Destroys a set instance.
Ssiter Sset_find (Sset_ptr self, Sset_key key)
 Looks up for an element with a given key.
Ssiter Sset_find_ge (Sset_ptr self, Sset_key key)
 Looks up for the closest element whose key is greater than or equal a given key.
Ssiter Sset_find_insert (Sset_ptr self, Sset_key key, boolean *is_found)
 Looks up for an element with a given key and if does not exist it is created.
Ssiter Sset_find_le (Sset_ptr self, Sset_key key)
 Looks up for the closest element whose key is less than or equal a given key.
Ssiter Sset_first (Sset_ptr self)
 Returns an iterator pointing to a first element of a set, i.e. element with the smallest key.
size_t Sset_get_size (Sset_ptr self)
 Returns the number of elements in a set.
boolean Sset_insert (Sset_ptr self, Sset_key key, void *element)
 Insert an element "element" under the key "key" into the set.
boolean Sset_is_empty (Sset_ptr self)
 Returns true iff the set is empty.
Ssiter Sset_last (Sset_ptr self)
 Returns an iterator pointing to the last element of a set, i.e. element with the greatest key.

Detailed Description

Public interface for a Sset (Sorted Set) class.

Author:
Andrei Tchaltsev See Sset.c file for description.

Implementation of Sset class


Friends And Related Function Documentation

Sset_ptr Sset_copy ( const Sset_ptr  self  )  [related]

Creates a copy of the given set instance.

Sset_ptr Sset_copy_func ( const Sset_ptr  self,
void *(*)(void *, void *)  func,
void *  arg 
) [related]

Creates a copy of the given set instance, copying each element by calling given function.

Sset_ptr Sset_create ( void   )  [related]

Creates an instance of a Sorted Set.

Keys are sorted as integers (< and == operators are used)

Sset_ptr Sset_create_with_param ( PFIVPVP  compare  )  [related]

Creates an instance of a Sorted Set with a comparing function.

void * Sset_delete ( Sset_ptr  self,
Sset_key  key,
boolean is_found 
) [related]

Removes an element with key "key" from the set.

The returned value is the element stored in the deleted node. If parameter "is_found" is no NULL, "*is_found" is set to true if such an element with the provided key was found, and false otherwise. Note: if an element with the key does no exist in the set the returned value is NULL.

The operation takes O(log2 N) time (N is the size of the set).

void Sset_delete_iter ( Sset_ptr  self,
Ssiter  iter 
) [related]

Removes an element pointed by the iterator.

Precondition: the iterator should be returned one by Ssiter_first, Ssiter_last, Ssiter_next, Ssiter_prev. Precondition: an element pointed by iterator has to belong to this set. Precondition: Ssiter_is_valid(iter) has to be return true.

WARNING: After this function call the iterator will have undefined value and no operation is allowed with it except assignment of a new value.

The operation takes O(log2 N) time (N is the size of the set).

void Sset_destroy ( Sset_ptr  self  )  [related]

Destroys a set instance.

The memory used by the set will be freed. Note: memory occupied by the elements is not freed! It is the user responsibility.

Ssiter Sset_find ( Sset_ptr  self,
Sset_key  key 
) [related]

Looks up for an element with a given key.

Returns an iterator pointing to the found element. If there is no such element Ssiter_is_valid() returns false on the returned iterator.

The operation takes O(log2 N) time (N is the size of the set).

Ssiter Sset_find_ge ( Sset_ptr  self,
Sset_key  key 
) [related]

Looks up for the closest element whose key is greater than or equal a given key.

Returns an iterator pointing to the found element. If there is no such element Ssiter_is_valid() returns false on the returned iterator.

The operation takes O(log2 N) time (N is the size of the set).

Ssiter Sset_find_insert ( Sset_ptr  self,
Sset_key  key,
boolean is_found 
) [related]

Looks up for an element with a given key and if does not exist it is created.

Returns an iterator pointing to the found (created) element. If is_found != NULL, *is_found is set to true if the element was found and false if it was created.

The operation takes O(log2 N) time (N is the size of the set).

It is user responsibility to free the key, if needed.

Ssiter Sset_find_le ( Sset_ptr  self,
Sset_key  key 
) [related]

Looks up for the closest element whose key is less than or equal a given key.

Returns an iterator pointing to the found element. If there is no such element Ssiter_is_valid() returns false on the returned iterator.

The operation takes O(log2 N) time (N is the size of the set).

Ssiter Sset_first ( Sset_ptr  self  )  [related]

Returns an iterator pointing to a first element of a set, i.e. element with the smallest key.

If the set is empty Ssiter_is_valid() will be false on the returned iterator. NOTE: there is no need to free the iterator after using it. NOTE: it is allowed to assign one iterator to another one. NOTE: The operation may take up to O(log2 N) time (N is the size of the set).

See also:
Ssiter_is_end, Ssiter_next, Ssiter_element
size_t Sset_get_size ( Sset_ptr  self  )  [related]

Returns the number of elements in a set.

Constant time operation

boolean Sset_insert ( Sset_ptr  self,
Sset_key  key,
void *  element 
) [related]

Insert an element "element" under the key "key" into the set.

Returns true if a new node was created and false if a node with the given key has already existed (in which case nothing is changed). Note: all the existing iterators remain valid.

It is user responsibility to free the key, if needed.

boolean Sset_is_empty ( Sset_ptr  self  )  [related]

Returns true iff the set is empty.

Constant time operation

Ssiter Sset_last ( Sset_ptr  self  )  [related]

Returns an iterator pointing to the last element of a set, i.e. element with the greatest key.

If the set is empty Ssiter_is_valid() will be false on the returned iterator. NOTE: there is no need to free the iterator after using it. NOTE: it is allowed to assign one iterator to another one. NOTE: The operation may take up to O(log2 N) time (N is the size of the set).

See also:
Ssiter_is_end, Ssiter_next, Ssiter_element

The documentation for this struct was generated from the following file:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on 14 Oct 2015 for NuSMV Developers Manual by  doxygen 1.6.1