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

NAME

8       struct::stack - Create and manipulate stack objects
9

SYNOPSIS

11       package require Tcl  8.4
12
13       package require struct::stack  ?1.5.3?
14
15       stackName option ?arg arg ...?
16
17       stackName clear
18
19       stackName destroy
20
21       stackName get
22
23       stackName getr
24
25       stackName peek ?count?
26
27       stackName peekr ?count?
28
29       stackName trim ?newsize?
30
31       stackName trim* ?newsize?
32
33       stackName pop ?count?
34
35       stackName push item ?item...?
36
37       stackName size
38
39______________________________________________________________________________
40

DESCRIPTION

42       The  ::struct  namespace  contains  a  commands  for  processing finite
43       stacks.
44
45       It exports a single command, ::struct::stack.  All  functionality  pro‐
46       vided here can be reached through a subcommand of this command.
47
48       Note:  As of version 1.3.3 of this package a critcl based C implementa‐
49       tion is available. This implementation however requires Tcl 8.4 to run.
50
51       The ::struct::stack command creates a new stack object with an  associ‐
52       ated  global  Tcl command whose name is stackName.  This command may be
53       used to invoke various operations on the stack.  It has  the  following
54       general form:
55
56       stackName option ?arg arg ...?
57              Option and the args determine the exact behavior of the command.
58              The following commands are possible for stack objects:
59
60       stackName clear
61              Remove all items from the stack.
62
63       stackName destroy
64              Destroy the stack, including its storage  space  and  associated
65              command.
66
67       stackName get
68              Returns  the  whole  contents  of  the  stack as a list, without
69              removing them from the stack.
70
71       stackName getr
72              A variant of get, which returns the contents in reversed order.
73
74       stackName peek ?count?
75              Return the top count items of the stack, without  removing  them
76              from  the  stack.   If count is not specified, it defaults to 1.
77              If count is 1, the result is a simple string; otherwise, it is a
78              list.   If  specified, count must be greater than or equal to 1.
79              If there are not enoughs items  on  the  stack  to  fulfull  the
80              request, this command will throw an error.
81
82       stackName peekr ?count?
83              A variant of peek, which returns the items in reversed order.
84
85       stackName trim ?newsize?
86              Shrinks  the  stack  to  contain  at  most  newsize elements and
87              returns a list containing the elements which were removed. Noth‐
88              ing  is  done  if the stack is already at the specified size, or
89              smaller. In that case the result is the empty list.
90
91       stackName trim* ?newsize?
92              A variant of trim which performs the  shrinking,  but  does  not
93              return the removed elements.
94
95       stackName pop ?count?
96              Return  the  top  count items of the stack, and remove them from
97              the stack.  If count is not specified, it  defaults  to  1.   If
98              count  is  1,  the result is a simple string; otherwise, it is a
99              list.  If specified, count must be greater than or equal  to  1.
100              If  there  are  not  enoughs  items  on the stack to fulfull the
101              request, this command will throw an error.
102
103       stackName push item ?item...?
104              Push the item or items specified onto the stack.  If  more  than
105              one  item  is  given,  they will be pushed in the order they are
106              listed.
107
108       stackName size
109              Return the number of items on the stack.
110

BUGS, IDEAS, FEEDBACK

112       This document, and the package it describes, will  undoubtedly  contain
113       bugs  and other problems.  Please report such in the category struct ::
114       stack of the  Tcllib  Trackers  [http://core.tcl.tk/tcllib/reportlist].
115       Please  also  report any ideas for enhancements you may have for either
116       package and/or documentation.
117
118       When proposing code changes, please provide unified diffs, i.e the out‐
119       put of diff -u.
120
121       Note  further  that  attachments  are  strongly  preferred over inlined
122       patches. Attachments can be made by going  to  the  Edit  form  of  the
123       ticket  immediately  after  its  creation, and then using the left-most
124       button in the secondary navigation bar.
125

KEYWORDS

127       graph, matrix, queue, tree
128

CATEGORY

130       Data structures
131
132
133
134tcllib                               1.5.3                    struct::stack(n)
Impressum