Set_t
Set_AddMembersFromList(
Set_t set,
const NodeList_ptr list
)
- Add in order (at the end) all new elements. Linear
time in the size of list if not frozen, linear time in size of
set + size of list if frozen. See description about the structure
Set_t for further information
- Side Effects If set is not frozen, set is changed internally
Set_t
Set_AddMember(
Set_t set,
Set_Element_t el
)
- Add in order (at the end) a new element. Constant time
if not frozen, linear time if frozen. See description about the
structure Set_t for further information
- Side Effects If set is not frozen, set is changed internally
boolean
Set_Contains(
const Set_t set1,
const Set_t set2
)
- Returns true iff set2 is a subset of set1. Linear in
the size of set2
Set_t
Set_Copy(
const Set_t set
)
- If the set was frozen, returned set is equal to the set
given as input, and its reference counting is incremented. See
description about the structure Set_t for further information
- See Also
Set_MakeSingleton
Set_t
Set_Difference(
Set_t set1,
const Set_t set2
)
- Computes the Set Difference. Linear time on the
cardinality of set1. See description about the structure Set_t for
further information
- Side Effects If set1 is not frozen, set1 is changed internally. If
after difference set1 is empty, it is also released and the empty
set is returned.
boolean
Set_Equals(
const Set_t set1,
const Set_t set2
)
- Returns true iff set1 contains the same elements of
set2. Linear in the size of set2
Set_t
Set_Freeze(
Set_t set
)
- Use when a set has to be memoized
or stored in memory permanently. When frozen, a set content is
frozen, meaning that no change can occur later on this set. If the
set is tried to be changed later, a new copy will be created and
changes will be applied to that copy. When a frozen set is copied, a
reference counter is incremented and the same instance is returned
in constant time. When a frozen set is destroyed, it is destroyed
only when its ref counter reaches 0 (meaning it is the very last
instance of that set). Set is also returned for a functional
flavour. See description about the structure Set_t for
further information
- Side Effects set is changed internally if not already frozen
Set_Iterator_t
Set_GetFirstIter(
Set_t set1
)
- Returns an iterator to the "first" element of the set.
Since sets are ordered, iterating through a set means to traverse
the elements into the set in the same chronological ordering they
have been previoulsy added to the set. If a set is changed, any
previous stored iterator on that set might become invalid.
Set_Element_t
Set_GetMember(
const Set_t set,
Set_Iterator_t iter
)
- Returns the element at given iterator
Set_Iterator_t
Set_GetNextIter(
Set_Iterator_t iter
)
- Returns the next iterator.
Since sets are ordered, iterating through a set means to traverse
the elements into the set in the same chronological ordering they
have been previoulsy added to the set. If a set is changed, any
previous stored iterator on that set might become invalid.
Set_t
Set_GetRest(
const Set_t set,
Set_Iterator_t from
)
- Given a set and an iterator within that set, returns a
new set containing all the elements that are found in to the input
set from the iterator to then end of the set. Returned set must be
disposed by the caller.
WARNING!! Deprecated method. This method is provided only for
backward compatibility and should be no longer used in new code.
int
Set_GiveCardinality(
const Set_t set
)
- Computes the cardinality of the given set. Constant time
Set_t
Set_Intersection(
Set_t set1,
const Set_t set2
)
- Computes the Set intersection. Linear time on the
cardinality of set1+set2. See description about the structure Set_t for
further information
- Side Effects If set1 is not frozen, set1 is changed internally. If
after intersection set1 is empty, it is also released and the empty
set is returned.
boolean
Set_Intersects(
const Set_t set1,
const Set_t set2
)
- Returns true iff set1 contains at least one element from
set2. Linear in the size of set1
boolean
Set_IsEmpty(
const Set_t set
)
- Checks for Set Emptiness. Constant time
boolean
Set_IsEndIter(
Set_Iterator_t iter
)
- Returns true if the set iterator is at the end of the
iteration
boolean
Set_IsMember(
const Set_t set,
Set_Element_t el
)
- Checks if the given element is a member of the
set. It returns True if it is a member, False
otherwise. Constant time
Set_t
Set_MakeEmpty(
)
- This function creates an empty set.
Set_t
Set_MakeFromUnion(
node_ptr _union
)
- Given an union node, builds a corresponding set
Set_t
Set_MakeSingleton(
Set_Element_t el
)
- Creates a set with a unique element.
Set_t
Set_Make(
node_ptr l
)
- Given a list, builds a corresponding set
- See Also
Set_MakeSingleton
void
Set_ReleaseSetOfSet(
Set_t set
)
- Assuming that an input set consists of elements each of
which is also a set this function applies Set_ReleaseSet to the input
set and every set in it.
- Side Effects Set_ReleaseSet
void
Set_ReleaseSet(
Set_t set
)
- Releases the memory associated to the given set. If the
set was frozen, reference counting is taken into account. See
description about the structure Set_t for further information
Set_t
Set_RemoveMember(
Set_t set,
Set_Element_t el
)
- The new set is returned. Linear time. See
description about the structure Set_t for further information
- Side Effects If set is not frozen, set is changed internally. If
after removal set is empty, it is also released.
NodeList_ptr
Set_Set2List(
const Set_t set
)
- Given a set, returns a corresponding list. Returned
list belongs to self and must be NOT freed nor changed by the caller.
- See Also
Set_MakeSingleton
Set_t
Set_Union(
Set_t set1,
const Set_t set2
)
- Computes the Union of two sets. If set1 is not frozen,
set1 is changed by adding members of set2. If set1 is frozen, it is
before copied into a new set.
If set1 is not frozen, complexity is linear in the cardinality od
set2, otherwise it is linear in the cardinality(set1) +
cardinality(set2)
See description about the structure Set_t for further information
- Side Effects If set is not frozen, set is changed internally.
Set_t
set_check_frozen(
Set_t self
)
- Used internally by functions that change the instance
to handle frozen set
void
set_check_list(
Set_t self
)
- This method is used internally to allow late allocation
of the list
Set_t
set_copy_actual(
const Set_t self
)
- Internal copy constructor
Set_t
set_copy(
const Set_t self
)
- Internal copy constructor
Set_t
set_create(
)
- Internal constructor
void
set_destroy(
Set_t self
)
- Internal destructor
void
set_pkg_init(
)
- Initializes the set package. See also Set_Quit() to
deinitialize it
void
set_pkg_quit(
)
- De-Initializes the set package. Use after Set_init()
void
set_union_to_set_aux(
node_ptr a,
Set_t* set
)
- Auxiliary function for constructor from union nodes
- Side Effects Given set will be added of found expressions