1struct::set(n)                Tcl Data Structures               struct::set(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       struct::set - Procedures for manipulating sets
9

SYNOPSIS

11       package require Tcl  8.0
12
13       package require struct::set  ?2.2.3?
14
15       ::struct::set empty set
16
17       ::struct::set size set
18
19       ::struct::set contains set item
20
21       ::struct::set union ?set1...?
22
23       ::struct::set intersect ?set1...?
24
25       ::struct::set difference set1 set2
26
27       ::struct::set symdiff set1 set2
28
29       ::struct::set intersect3 set1 set2
30
31       ::struct::set equal set1 set2
32
33       ::struct::set include svar item
34
35       ::struct::set exclude svar item
36
37       ::struct::set add svar set
38
39       ::struct::set subtract svar set
40
41       ::struct::set subsetof A B
42
43_________________________________________________________________
44

DESCRIPTION

46       The  ::struct::set  namespace contains several useful commands for pro‐
47       cessing finite sets.
48
49       It exports only a single command, struct::set. All  functionality  pro‐
50       vided here can be reached through a subcommand of this command.
51
52       Note: As of version 2.2 of this package a critcl based C implementation
53       is available. This implementation however requires Tcl 8.4 to run.
54

COMMANDS

56       ::struct::set empty set
57              Returns a boolean value indicating if the set is  empty  (true),
58              or not (false).
59
60       ::struct::set size set
61              Returns an integer number greater than or equal to zero. This is
62              the number of elements in the set. In other words, its cardinal‐
63              ity.
64
65       ::struct::set contains set item
66              Returns  a boolean value indicating if the set contains the ele‐
67              ment item (true), or not (false).
68
69       ::struct::set union ?set1...?
70              Computes the set containing the union of set1, set2, etc.,  i.e.
71              "set1  +  set2 + ...", and returns this set as the result of the
72              command.
73
74       ::struct::set intersect ?set1...?
75              Computes the set containing  the  intersection  of  set1,  set2,
76              etc.,  i.e.  "set1  *  set2  * ...", and returns this set as the
77              result of the command.
78
79       ::struct::set difference set1 set2
80              Computes the set containing the difference  of  set1  and  set2,
81              i.e.  ("set1  - set2") and returns this set as the result of the
82              command.
83
84       ::struct::set symdiff set1 set2
85              Computes the set containing the symmetric difference of set1 and
86              set2,  i.e.  ("(set1  - set2) + (set2 - set1)") and returns this
87              set as the result of the command.
88
89       ::struct::set intersect3 set1 set2
90              This command is a combination of the methods intersect and  dif‐
91              ference.    It   returns   a   three-element   list   containing
92              "set1*set2", "set1-set2", and "set2-set1",  in  this  order.  In
93              other  words,  the  intersection  of the two parameter sets, and
94              their differences.
95
96       ::struct::set equal set1 set2
97              Returns a boolean value indicating if the  two  sets  are  equal
98              (true) or not (false).
99
100       ::struct::set include svar item
101              The  element  item is added to the set specified by the variable
102              name in svar. The return value of the command is empty. This  is
103              the  equivalent  of  lappend  for sets. If the variable named by
104              svar does not exist it will be created.
105
106       ::struct::set exclude svar item
107              The element item is removed from the set specified by the  vari‐
108              able  name  in  svar.  The return value of the command is empty.
109              This is a near-equivalent of lreplace for sets.
110
111       ::struct::set add svar set
112              All the element of set are added to the  set  specified  by  the
113              variable name in svar. The return value of the command is empty.
114              This is like the method include, but for the addition of a whole
115              set.  If  the  variable  named by svar does not exist it will be
116              created.
117
118       ::struct::set subtract svar set
119              All the element of set are removed from the set specified by the
120              variable name in svar. The return value of the command is empty.
121              This is like the method exclude, but for the removal of a  whole
122              set.
123
124       ::struct::set subsetof A B
125              Returns a boolean value indicating if the set A is a true subset
126              of or equal to the set B (true), or not (false).
127

REFERENCES

BUGS, IDEAS, FEEDBACK

130       This document, and the package it describes, will  undoubtedly  contain
131       bugs  and other problems.  Please report such in the category struct ::
132       set     of     the     Tcllib     SF      Trackers      [http://source
133       forge.net/tracker/?group_id=12883].   Please  also report any ideas for
134       enhancements you may have for either package and/or documentation.
135

KEYWORDS

137       cardinality, difference, emptiness, exclusion, inclusion, intersection,
138       membership, set, symmetric difference, union
139
141       Copyright (c) 2004-2008 Andreas Kupries <andreas_kupries@users.sourceforge.net>
142
143
144
145
146struct                               2.2.3                      struct::set(n)
Impressum