struct::set - Procedures for manipulating sets
Contents
Bugs, Ideas, Feedback
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please
report such in the category struct::set of the TcllibTrackers [http://core.tcl.tk/tcllib/reportlist].
Please also report any ideas for enhancements you may have for either package and/or documentation.
When proposing code changes, please provide unifieddiffs, i.e the output of diff-u.
Note further that attachments are strongly preferred over inlined patches. Attachments can be made by
going to the Edit form of the ticket immediately after its creation, and then using the left-most button
in the secondary navigation bar.
Category
Data structures
Commands
::struct::setemptyset
Returns a boolean value indicating if the set is empty (true), or not (false).
::struct::setsizeset
Returns an integer number greater than or equal to zero. This is the number of elements in the
set. In other words, its cardinality.
::struct::setcontainssetitem
Returns a boolean value indicating if the set contains the element item (true), or not (false).
::struct::setunion ?set1...?
Computes the set containing the union of set1, set2, etc., i.e. "set1 + set2 + ...", and returns
this set as the result of the command.
::struct::setintersect ?set1...?
Computes the set containing the intersection of set1, set2, etc., i.e. "set1 * set2 * ...", and
returns this set as the result of the command.
::struct::setdifferenceset1set2
Computes the set containing the difference of set1 and set2, i.e. ("set1 - set2") and returns this
set as the result of the command.
::struct::setsymdiffset1set2
Computes the set containing the symmetric difference of set1 and set2, i.e. ("(set1 - set2) +
(set2 - set1)") and returns this set as the result of the command.
::struct::setintersect3set1set2
This command is a combination of the methods intersect and difference. It returns a three-element
list containing "set1*set2", "set1-set2", and "set2-set1", in this order. In other words, the
intersection of the two parameter sets, and their differences.
::struct::setequalset1set2
Returns a boolean value indicating if the two sets are equal (true) or not (false).
::struct::setincludesvaritem
The element item is added to the set specified by the variable name in svar. The return value of
the command is empty. This is the equivalent of lappend for sets. If the variable named by svar
does not exist it will be created.
::struct::setexcludesvaritem
The element item is removed from the set specified by the variable name in svar. The return value
of the command is empty. This is a near-equivalent of lreplace for sets.
::struct::setaddsvarset
All the element of set are added to the set specified by the variable name in svar. The return
value of the command is empty. This is like the method include, but for the addition of a whole
set. If the variable named by svar does not exist it will be created.
::struct::setsubtractsvarset
All the element of set are removed from the set specified by the variable name in svar. The return
value of the command is empty. This is like the method exclude, but for the removal of a whole
set.
::struct::setsubsetofAB
Returns a boolean value indicating if the set A is a true subset of or equal to the set B (true),
or not (false).
Copyright
Copyright (c) 2004-2008 Andreas Kupries <andreas_kupries@users.sourceforge.net>
tcllib 2.2.5 struct::set(3tcl)
Description
The ::struct::set namespace contains several useful commands for processing finite sets.
It exports only a single command, struct::set. All functionality provided here can be reached through a
subcommand of this command.
Note: As of version 2.2 of this package a critcl based C implementation is available. This implementation
however requires Tcl 8.4 to run.
Keywords
cardinality, difference, emptiness, exclusion, inclusion, intersection, membership, set, symmetric
difference, union
Name
struct::set - Procedures for manipulating sets
References
Synopsis
package require Tcl8.59
package require struct::set?2.2.4?::struct::setemptyset::struct::setsizeset::struct::setcontainssetitem::struct::setunion ?set1...?
::struct::setintersect ?set1...?
::struct::setdifferenceset1set2::struct::setsymdiffset1set2::struct::setintersect3set1set2::struct::setequalset1set2::struct::setincludesvaritem::struct::setexcludesvaritem::struct::setaddsvarset::struct::setsubtractsvarset::struct::setsubsetofAB
________________________________________________________________________________________________________________
