1443
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2003 by eXept Software AG
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
1231
|
13 |
"{ Package: 'stx:libbasic3' }"
|
|
14 |
|
|
15 |
"{ NameSpace: Packages }"
|
|
16 |
|
|
17 |
Object subclass:#DictionaryStack
|
|
18 |
instanceVariableNames:'collection'
|
|
19 |
classVariableNames:''
|
|
20 |
poolDictionaries:''
|
|
21 |
category:'Package-helpers'
|
|
22 |
!
|
|
23 |
|
1443
|
24 |
!DictionaryStack class methodsFor:'documentation'!
|
|
25 |
|
|
26 |
copyright
|
|
27 |
"
|
|
28 |
COPYRIGHT (c) 2003 by eXept Software AG
|
|
29 |
All Rights Reserved
|
|
30 |
|
|
31 |
This software is furnished under a license and may be used
|
|
32 |
only in accordance with the terms of that license and with the
|
|
33 |
inclusion of the above copyright notice. This software may not
|
|
34 |
be provided or otherwise made available to, or used by, any
|
|
35 |
other person. No title to or ownership of the software is
|
|
36 |
hereby transferred.
|
|
37 |
"
|
|
38 |
! !
|
1231
|
39 |
|
|
40 |
!DictionaryStack class methodsFor:'instance creation'!
|
|
41 |
|
|
42 |
new
|
|
43 |
^ self basicNew initialize.
|
|
44 |
! !
|
|
45 |
|
|
46 |
!DictionaryStack methodsFor:'* As yet uncategorized *'!
|
|
47 |
|
|
48 |
collect:aBlock
|
|
49 |
^ collection values collect:aBlock
|
|
50 |
! !
|
|
51 |
|
|
52 |
!DictionaryStack methodsFor:'adding & removing'!
|
|
53 |
|
|
54 |
atKey:aSymbol
|
|
55 |
|
|
56 |
^ collection at:aSymbol
|
|
57 |
!
|
|
58 |
|
|
59 |
atKey:aSymbol ifAbsent:aBlock
|
|
60 |
|
|
61 |
^ collection at:aSymbol ifAbsent:aBlock
|
|
62 |
!
|
|
63 |
|
|
64 |
pop
|
|
65 |
collection removeKey:collection last key
|
|
66 |
!
|
|
67 |
|
|
68 |
pop:aNumber
|
|
69 |
|
|
70 |
aNumber timesRepeat:[ self pop].
|
|
71 |
!
|
|
72 |
|
|
73 |
popAt:aKey
|
|
74 |
collection removeKey:aKey.
|
|
75 |
!
|
|
76 |
|
|
77 |
popAt:aKey ifAbsent:aBlock
|
|
78 |
collection removeKey:aKey ifAbsent:aBlock.
|
|
79 |
!
|
|
80 |
|
|
81 |
pull
|
|
82 |
^ self pop
|
|
83 |
!
|
|
84 |
|
|
85 |
pull:aNumber
|
|
86 |
| col |
|
|
87 |
col := collection last:aNumber.
|
|
88 |
self pop:aNumber.
|
|
89 |
^ col
|
|
90 |
!
|
|
91 |
|
|
92 |
pullAt:aKey
|
|
93 |
^ collection removeKey:aKey.
|
|
94 |
!
|
|
95 |
|
|
96 |
pullAt:aKey ifAbsent:aBlock
|
|
97 |
^ collection removeKey:aKey ifAbsent:aBlock.
|
|
98 |
!
|
|
99 |
|
|
100 |
push:aPackage
|
|
101 |
|
|
102 |
^ collection at:aPackage name put:aPackage
|
|
103 |
!
|
|
104 |
|
|
105 |
removeKey:aSymbol
|
|
106 |
|
|
107 |
^ collection removeKey:aSymbol
|
|
108 |
!
|
|
109 |
|
|
110 |
top
|
|
111 |
^ collection last value
|
|
112 |
! !
|
|
113 |
|
|
114 |
!DictionaryStack methodsFor:'enumerating'!
|
|
115 |
|
|
116 |
do:aBlock
|
|
117 |
"goes through all the objects in the collection"
|
|
118 |
collection reverseDo:[:anAssociation | aBlock value:anAssociation value]
|
|
119 |
!
|
|
120 |
|
|
121 |
select:aBlock
|
|
122 |
^ collection values select:aBlock
|
|
123 |
! !
|
|
124 |
|
|
125 |
!DictionaryStack methodsFor:'initialization'!
|
|
126 |
|
|
127 |
initialize
|
|
128 |
collection := OrderedDictionary new.
|
|
129 |
! !
|
|
130 |
|
|
131 |
!DictionaryStack methodsFor:'queries'!
|
|
132 |
|
|
133 |
includes:aPackage
|
|
134 |
^ collection includes:aPackage
|
|
135 |
!
|
|
136 |
|
|
137 |
includesKey:aKey
|
|
138 |
^ (collection includesKey:aKey)
|
|
139 |
!
|
|
140 |
|
|
141 |
isEmpty
|
|
142 |
^ collection isEmpty
|
|
143 |
!
|
|
144 |
|
|
145 |
size
|
|
146 |
^ collection size
|
|
147 |
! !
|
|
148 |
|
|
149 |
!DictionaryStack class methodsFor:'documentation'!
|
|
150 |
|
|
151 |
version
|
1443
|
152 |
^ '$Header: /cvs/stx/stx/libbasic3/packages/DictionaryStack.st,v 1.2 2006-01-10 09:25:12 cg Exp $'
|
1231
|
153 |
! !
|