OrderedDictionary.st
author Claus Gittinger <cg@exept.de>
Thu, 08 Nov 2007 17:34:59 +0100
changeset 1913 4c2622e92a91
parent 1589 f0607bf986e0
child 1917 61c602336f3d
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
     1
"
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
     2
 COPYRIGHT.
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
     3
 This is a Manchester Goodie protected by copyright.
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
     4
 These conditions are imposed on the whole Goodie, and on any significant
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
     5
 part of it which is separately transmitted or stored:
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
     6
	* You must ensure that every copy includes this notice, and that
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
     7
	  source and author(s) of the material are acknowledged.
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
     8
	* These conditions must be imposed on anyone who receives a copy.
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
     9
	* The material shall not be used for commercial gain without the prior
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
    10
	  written consent of the author(s).
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
    11
 Further information on the copyright conditions may be obtained by
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
    12
 sending electronic mail:
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
    13
	To: goodies-lib@cs.man.ac.uk
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
    14
	Subject: copyright
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
    15
 or by writing to The Smalltalk Goodies Library Manager, Dept of
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
    16
 Computer Science, The University, Manchester M13 9PL, UK
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
    17
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
    18
 (C) Copyright 1992 University of Manchester
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
    19
 For more information about the Manchester Goodies Library (from which 
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
    20
 this file was distributed) send e-mail:
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
    21
	To: goodies-lib@cs.man.ac.uk
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
    22
	Subject: help 
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
    23
"
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
    24
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
    25
"{ Package: 'stx:libbasic2' }"
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
    26
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
    27
Dictionary subclass:#OrderedDictionary
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
    28
	instanceVariableNames:'order'
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
    29
	classVariableNames:''
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
    30
	poolDictionaries:''
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
    31
	category:'Collections-Sequenceable'
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
    32
!
a759b5c72c98 Initial revision
claus
parents:
diff changeset
    33
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
    34
!OrderedDictionary class methodsFor:'documentation'!
498
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    35
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    36
copyright
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    37
"
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    38
 COPYRIGHT.
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    39
 This is a Manchester Goodie protected by copyright.
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    40
 These conditions are imposed on the whole Goodie, and on any significant
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    41
 part of it which is separately transmitted or stored:
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    42
	* You must ensure that every copy includes this notice, and that
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    43
	  source and author(s) of the material are acknowledged.
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    44
	* These conditions must be imposed on anyone who receives a copy.
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    45
	* The material shall not be used for commercial gain without the prior
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    46
	  written consent of the author(s).
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    47
 Further information on the copyright conditions may be obtained by
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    48
 sending electronic mail:
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    49
	To: goodies-lib@cs.man.ac.uk
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    50
	Subject: copyright
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    51
 or by writing to The Smalltalk Goodies Library Manager, Dept of
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    52
 Computer Science, The University, Manchester M13 9PL, UK
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    53
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    54
 (C) Copyright 1992 University of Manchester
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    55
 For more information about the Manchester Goodies Library (from which 
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    56
 this file was distributed) send e-mail:
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    57
	To: goodies-lib@cs.man.ac.uk
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    58
	Subject: help 
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    59
"
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    60
!
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
    61
498
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    62
documentation
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    63
"
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    64
    I am a subclass of Dictionary whose elements (associations) are ordered in a
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    65
    similar fashion to OrderedCollection.
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
    66
    That is, while being filled via #at:put: messages (or similar Dictionary protocol),
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
    67
    the order in which associations are added is remembered and accessable via the #atIndex:
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
    68
    or #order messages.
498
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    69
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    70
    I have one instance variable:
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    71
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    72
    order <OrderedCollection>       Ordered collection of keys reflecting the order of
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
    73
                                    associations in the dictionary.
498
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    74
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    75
    [author:]
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
    76
        Ifor Wyn Williams <ifor@uk.ac.man.cs>
498
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    77
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
    78
    [see also:]
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
    79
        OrderedCollection Dictionary
1581
201be7d15ef0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1571
diff changeset
    80
        OrderedSet
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
    81
"
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
    82
!
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
    83
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
    84
examples
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
    85
"
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
    86
    |o|
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
    87
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
    88
    o := OrderedDictionary new.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
    89
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
    90
    o at:'one'   put:1.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
    91
    o at:'two'   put:2.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
    92
    o at:'three' put:3.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
    93
    o at:'four'  put:4.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
    94
    o at:'five'  put:5.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
    95
    o at:'six'   put:6.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
    96
    o at:'seven' put:7.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
    97
    o at:'eight' put:8.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
    98
    o at:'nine'  put:9.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
    99
    o at:'zero'  put:0.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   100
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   101
    o at:'eight'.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   102
    o atIndex:1.   
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   103
    o atIndex:5.    
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   104
    o atIndex:10.  
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   105
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   106
    o from:3 to:6 do:[:each | Transcript showCR:each ].
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   107
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   108
    o collect:[:eachAssoc | eachAssoc key -> eachAssoc value squared]. 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   109
    o associations.  
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   110
    o order.         
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   111
    o reverse.    
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   112
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   113
    o atIndex:1.  
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   114
    o atIndex:5. 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   115
    o atIndex:10. 
498
90e67ae0c062 tuned #at:put:
Claus Gittinger <cg@exept.de>
parents: 497
diff changeset
   116
"
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   117
!
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   118
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   119
info
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   120
"
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   121
	NAME            OrderedDictionary
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   122
	AUTHOR          Ifor Wyn Williams <ifor@uk.ac.man.cs>
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   123
	CONTRIBUTOR     Ifor Wyn Williams <ifor@uk.ac.man.cs>
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   124
	FUNCTION        An ordered dictionary
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   125
	ST-VERSIONS     2.3-5, 4.0
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   126
	PREREQUISITES   
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   127
	CONFLICTS       
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   128
	DISTRIBUTION    global
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   129
	VERSION         1.2
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   130
	DATE            28.3.90
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   131
	SUMMARY         A dictionary that behaves like a SequencableCollection
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   132
			(except that associations cannot be removed). 
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   133
"
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   134
! !
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   135
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   136
!OrderedDictionary class methodsFor:'instance creation'!
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   137
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   138
new
1571
fa44f16fd6cd proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
   139
        ^ super new initializeOrder
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   140
!
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   141
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   142
new: anInteger
1571
fa44f16fd6cd proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
   143
        ^(super new: anInteger) initializeOrder
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   144
! !
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   145
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   146
!OrderedDictionary methodsFor:'accessing'!
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   147
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   148
after: anAssociation 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   149
    "Return the association after anAssociation in the order. 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   150
     If anAssociation is the last association in the order, return nil. 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   151
     If anAssociation is not found, invoke an error notifier"
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   152
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   153
    1 to: order size - 1 do: [:index | (self associationAt: (order at: index))
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   154
                    = anAssociation ifTrue: [^self associationAt: (order at: index + 1)]].
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   155
    (self associationAt: (order last))
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   156
            = anAssociation
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   157
            ifTrue: [^nil]
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   158
            ifFalse: [^self error: 'not found']
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   159
!
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   160
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   161
associations
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   162
    "Return an OrderedCollection containing the receiver's associations."
497
1337168140ae added #addAllAssociations: , #addAllAssociationsFirst: and #addAllAssociationsLast:
Claus Gittinger <cg@exept.de>
parents: 457
diff changeset
   163
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   164
    ^ order collect: [:key | self associationAt: key ].
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   165
!
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   166
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   167
at:aKey ifAbsentPut:valueBlock
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   168
    |val|
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   169
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   170
    ^ self at:aKey ifAbsent:[ self at:aKey put:valueBlock value ]
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   171
!
497
1337168140ae added #addAllAssociations: , #addAllAssociationsFirst: and #addAllAssociationsLast:
Claus Gittinger <cg@exept.de>
parents: 457
diff changeset
   172
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   173
at: key put: anObject 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   174
    "Set the value at key to be anObject. 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   175
     If key is not found, create a new entry for key and set is value to anObject. 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   176
     If key is already present, the order remains unchanged.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   177
     Return anObject."
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   178
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   179
    "/ claus: super can check this much faster ...
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   180
    "/ (super includesKey:key)
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   181
    "/ ... but that leads to trouble in add:* methods. (sigh)
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   182
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   183
    (order includes: key)
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   184
            ifFalse: [order add: key].
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   185
    ^ super at: key put: anObject
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   186
!
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   187
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   188
atAll:indexCollection put: anObject 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   189
    "Put anObject into the value field of every association specified by indexCollection,
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   190
     which is typically an interval."
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   191
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   192
    indexCollection do:[:index | self at:(order at: index) put:anObject]
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   193
!
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   194
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   195
atAllPut: anObject 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   196
    "Put anObject into the value field of every association in the dictionary"
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   197
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   198
    order do: [:key | self at: key put: anObject]
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   199
!
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   200
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   201
atIndex:index
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   202
    "return an element at a given index"
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   203
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   204
    ^ self at:(order at:index)
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   205
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   206
    "Created: 28.9.1995 / 13:49:39 / stefan"
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   207
!
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   208
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   209
atIndex:index put:anAssociation
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   210
    "put an association to a given index. remove the old associatioan at this index"
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   211
    |key|
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   212
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   213
    key := anAssociation key.
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   214
    (super includesKey:key) ifTrue:[
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   215
        ^ self error:'duplicate key'.
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   216
    ].
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   217
    super removeKey:(order at:index) ifAbsent:[].
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   218
    order at:index put:key.
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   219
    ^ super add:anAssociation.
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   220
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   221
    "Created: 28.9.1995 / 16:30:15 / stefan"
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   222
!
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   223
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   224
before: anAssociation 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   225
    "Return the association before anAssociation in the order. 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   226
     If anAssociation is the first association in the order, return nil. 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   227
     If anAssociation is not found, invoke an error notifier"
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   228
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   229
    2 to:order size do:[:index | 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   230
        (self associationAt:(order at:index)) = anAssociation 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   231
            ifTrue:[ ^ self associationAt:(order at:index - 1)] 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   232
    ].
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   233
    (self associationAt:order first) = anAssociation ifTrue: [^ nil].
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   234
    ^ self error: 'not found'
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   235
!
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   236
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   237
first
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   238
    "Return the first association of the receiver.  
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   239
     Provide an error notification if the receiver contains no elements."
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   240
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   241
    order emptyCheck.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   242
    ^ self associationAt: (order first)
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   243
!
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   244
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   245
keyAt:index
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   246
    "get the key at the given index"
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   247
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   248
    ^ order at:index.
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   249
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   250
    "Created: 29.9.1995 / 11:32:07 / stefan"
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   251
!
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   252
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   253
keys
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   254
    "Return a OrderedCollection containing the receiver's keys."
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   255
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   256
    ^ order copy.
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   257
!
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   258
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   259
last
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   260
    "Return the last association of the receiver. 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   261
     Provide an error notification if the receiver contains no elements."
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   262
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   263
    order emptyCheck.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   264
    ^ self associationAt: (order last)
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   265
!
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   266
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   267
order
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   268
    "returns the values in the order of their appearance"
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   269
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   270
    ^ order
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   271
!
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   272
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   273
values
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   274
    "Return a OrderedCollection containing the receiver's values."
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   275
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   276
    ^ order collect: [:key | (self at: key) ].
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   277
! !
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   278
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   279
!OrderedDictionary methodsFor:'adding'!
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   280
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   281
add: anAssociation 
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   282
      "add anAssociation to the dictionary"
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   283
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   284
      | key |
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   285
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   286
      key := anAssociation key.
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   287
      (super includesKey: key)
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   288
              ifFalse: [order add: key].
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   289
      ^ super add: anAssociation
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   290
!
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   291
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   292
add: anAssociation after: oldAssociation 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   293
    "Add the argument, anAssociation, as an element of the dictionary. Put it 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   294
    in the position just succeeding oldAssociation. Return anAssociation."
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   295
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   296
    | index |
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   297
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   298
    index := self indexOfAssociation: oldAssociation 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   299
                            ifAbsent: [self error: 'association not found'].
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   300
    self removeFromOrder: anAssociation key.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   301
    order add: anAssociation key after: (order at: index).
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   302
    super add: anAssociation.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   303
    ^ anAssociation
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   304
!
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   305
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   306
add: anAssociation before: oldAssociation 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   307
    "Add the argument, anAssociation, as an element of the dictionary. Put it 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   308
    in the position just preceding oldAssociation. Return anAssociation."
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   309
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   310
    | index |
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   311
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   312
    index := self indexOfAssociation: oldAssociation 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   313
                            ifAbsent: [self error: 'association not found'].
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   314
    self removeFromOrder: anAssociation key.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   315
    order add: anAssociation key before: (order at: index).
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   316
    super add: anAssociation.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   317
    ^ anAssociation
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   318
!
504
df82d5a5de53 undone last change - all add: methods have trouble with that....
Claus Gittinger <cg@exept.de>
parents: 503
diff changeset
   319
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   320
add: anAssociation beforeIndex: spot 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   321
    "Add the argument, anAssociation, as an element of the receiver.  Put it
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   322
    in the position just preceding the indexed position spot.  Return newObject."
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   323
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   324
    self removeFromOrder: anAssociation key.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   325
    order add: anAssociation key beforeIndex: spot.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   326
    ^ super add: anAssociation
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   327
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   328
    "Modified: 28.9.1995 / 14:06:53 / stefan"
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   329
!
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   330
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   331
addAll:aCollectionOfAssociations 
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   332
    "Add each element of anOrderedCollectionOfAssociations at my end. 
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   333
     We expect the argument to enumerate associations with #reverseDo:; 
1348
c70abbed0c65 comment
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   334
     if it does not (i.e. it is another OD or a dictionary), use #addAllAssociationsFirst:.
c70abbed0c65 comment
Claus Gittinger <cg@exept.de>
parents: 1242
diff changeset
   335
     Returns the argument, aCollectionOfAssociations (sigh)."
120
fa3590433788 New methods for SequencableCollection access.
Stefan Vogel <sv@exept.de>
parents: 67
diff changeset
   336
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   337
    self addAllLast:aCollectionOfAssociations.
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   338
    ^ aCollectionOfAssociations
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   339
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   340
    "Modified: 28.2.1997 / 15:51:23 / cg"
120
fa3590433788 New methods for SequencableCollection access.
Stefan Vogel <sv@exept.de>
parents: 67
diff changeset
   341
!
fa3590433788 New methods for SequencableCollection access.
Stefan Vogel <sv@exept.de>
parents: 67
diff changeset
   342
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   343
addAllAssociations:aDictionaryOrOrderedDictionary
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   344
    "Add each association of aDictionaryOrOrderedDictionary to my end.
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   345
     We expect the argument to respond to #associationsDo:."
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   346
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   347
    self addAllAssociationsLast:aDictionaryOrOrderedDictionary.
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   348
    ^ aDictionaryOrOrderedDictionary
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   349
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   350
    "Created: 28.2.1997 / 15:52:02 / cg"
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   351
!
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   352
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   353
addAllAssociationsFirst:aDictionaryOrOrderedDictionary
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   354
    "Add each association of aDictionaryOrOrderedDictionary at the beginning of the 
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   355
     receiver. We expect the argument to respond to #associationsReverseDo:."
120
fa3590433788 New methods for SequencableCollection access.
Stefan Vogel <sv@exept.de>
parents: 67
diff changeset
   356
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   357
    aDictionaryOrOrderedDictionary associationsReverseDo:[:each | self addFirst:each].
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   358
    ^ aDictionaryOrOrderedDictionary
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   359
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   360
    "Created: 28.2.1997 / 15:50:14 / cg"
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   361
!
120
fa3590433788 New methods for SequencableCollection access.
Stefan Vogel <sv@exept.de>
parents: 67
diff changeset
   362
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   363
addAllAssociationsLast:aDictionaryOrOrderedDictionary
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   364
    "Add each association of aDictionaryOrOrderedDictionary at the end of the 
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   365
     receiver. We expect the argument to respond to #associationsDo:."
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   366
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   367
    aDictionaryOrOrderedDictionary associationsDo:[:each | self addLast:each].
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   368
    ^ aDictionaryOrOrderedDictionary
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   369
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   370
    "Created: 28.2.1997 / 15:48:37 / cg"
120
fa3590433788 New methods for SequencableCollection access.
Stefan Vogel <sv@exept.de>
parents: 67
diff changeset
   371
!
fa3590433788 New methods for SequencableCollection access.
Stefan Vogel <sv@exept.de>
parents: 67
diff changeset
   372
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   373
addFirst: anAssociation 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   374
    "Add anAssociation to the beginning of the receiver."
120
fa3590433788 New methods for SequencableCollection access.
Stefan Vogel <sv@exept.de>
parents: 67
diff changeset
   375
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   376
    self removeFromOrder: anAssociation key.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   377
    order addFirst: anAssociation key.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   378
    ^ super add: anAssociation.
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   379
!
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   380
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   381
addLast: anAssociation 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   382
    "Add anAssociation to the end of the receiver."
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   383
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   384
    self removeFromOrder: anAssociation key.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   385
    order addLast: anAssociation key.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   386
    ^ super add: anAssociation.
838
9454fd75930e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   387
! !
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   388
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   389
!OrderedDictionary methodsFor:'copying'!
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   390
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   391
copyEmpty
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   392
    "Return a copy of the receiver that contains no elements."
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   393
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   394
    ^ (self class) new: 10
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   395
!
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   396
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   397
copyEmpty: aSize
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   398
    "Return a copy of the receiver that contains no elements."
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   399
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   400
    ^ (self class) new: aSize
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   401
!
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   402
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   403
copyFrom: startIndex to: endIndex 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   404
    "Return a copy of the receiver that contains elements from 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   405
     position startIndex to endIndex."
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   406
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   407
    | newDict |
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   408
    endIndex < startIndex ifTrue: [^self copyEmpty].
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   409
    (startIndex < 1 or: [endIndex > order size])
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   410
            ifTrue: [^self error: 'No such element'].
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   411
    newDict := self copyEmpty: endIndex - startIndex + 1.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   412
    startIndex to: endIndex do: [:index | newDict add: (self associationAt: (order at: index))].
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   413
    ^ newDict
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   414
!
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   415
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   416
copyWith: anAssociation 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   417
    "Return a copy of the dictionary that is 1 bigger than the receiver and 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   418
     includes the argument, anAssociation, at the end."
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   419
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   420
    | newDict |
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   421
    newDict := self copy.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   422
    newDict add: anAssociation.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   423
    ^ newDict
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   424
!
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   425
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   426
copyWithout: anAssociation 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   427
    "Return a copy of the dictionary that is 1 smaller than the receiver and 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   428
     does not include the argument, anAssociation"
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   429
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   430
    | newDict |
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   431
    newDict := OrderedDictionary new: order size - 1.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   432
    self associationsDo: [:assoc | anAssociation = assoc ifFalse: [newDict add: assoc]]
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   433
! !
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   434
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   435
!OrderedDictionary methodsFor:'enumerating'!
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   436
1589
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   437
associationsCollect: aBlock 
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   438
    "Evaluate aBlock with each of the associations of the dictionary as argument,
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   439
     and return a new (ordered) collection with the results"
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   440
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   441
    ^ order collect:[:key | (aBlock value: (self associationAt:key))].
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   442
!
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   443
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   444
associationsDo: aBlock 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   445
    "Evaluate aBlock for each of the dictionary's associations."
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   446
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   447
    order do: [:key | aBlock value: (self associationAt: key)]
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   448
!
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   449
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   450
associationsDo: aBlock from: firstIndex to: secondIndex 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   451
    "Evaluate aBlock with each of the dictionary's associations from index 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   452
    firstIndex to index secondIndex as the argument."
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   453
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   454
    firstIndex to: secondIndex do: [:index | 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   455
        aBlock value: (self associationAt: (order at: index))
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   456
    ]
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   457
!
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   458
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   459
associationsReverseDo: aBlock 
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   460
    "Evaluate aBlock for each of the dictionary's associations in reverse order."
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   461
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   462
    order reverseDo:[:key | aBlock value:(self associationAt:key)]
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   463
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   464
    "Created: 28.2.1997 / 15:52:31 / cg"
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   465
!
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   466
1589
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   467
associationsSelect:aBlock 
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   468
    "Evaluate aBlock with each of the dictionary's associations as the argument.
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   469
     Collect into a new OrderedDictionary only those associations for which 
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   470
     aBlock evaluates to true. Return the new OrderedDictionary."
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   471
1589
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   472
    |newDict|
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   473
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   474
    newDict := OrderedDictionary new.
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   475
    order do:[:key | 
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   476
        |assoc|
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   477
1589
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   478
        assoc := self associationAt:key.
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   479
        (aBlock value:assoc) ifTrue: [
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   480
            newDict add:assoc
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   481
        ]
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   482
    ].
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   483
    ^ newDict
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   484
!
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   485
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   486
collect: aBlock 
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   487
    "Evaluate aBlock with each of the values of the dictionary as argument,
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   488
     and return a new (ordered) collection with the results"
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   489
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   490
    ^ order collect:[:key | (aBlock value: (self at:key))].
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   491
!
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   492
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   493
do: aBlock 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   494
    "Evaluate aBlock for each of the dictionary's values."
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   495
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   496
    order do: [:key | aBlock value: (self at: key)]
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   497
!
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   498
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   499
do: aBlock from: firstIndex to: lastIndex 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   500
    "Evaluate aBlock with each of the dictionary's associations from index 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   501
    firstIndex to index secondIndex as the argument."
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   502
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   503
    self from:firstIndex to:lastIndex do:aBlock.
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   504
!
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   505
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   506
findFirst: aBlock 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   507
    "Return the index of the first association in the dictionary for which aBlock
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   508
    evaluates as true. If the block does not evaluate to true, return 0"
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   509
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   510
    1 to:order size do:[:index | 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   511
        (aBlock value:(self associationAt:(order at:index))) ifTrue: [^ index]
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   512
    ].
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   513
    ^ 0
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   514
!
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   515
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   516
findLast:aBlock 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   517
    "Return the index of the last association in the dictionary for which aBlock
1424
459c00460dc0 + findLast:startingAt:endingAt:
ca
parents: 1348
diff changeset
   518
     evaluates as true. If the block does not evaluate to true, return 0"
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   519
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   520
    order size to:1 by:-1 do: [:index | 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   521
        (aBlock value:(self associationAt:(order at:index))) ifTrue: [^ index]
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   522
    ].
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   523
    ^ 0
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   524
!
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   525
1424
459c00460dc0 + findLast:startingAt:endingAt:
ca
parents: 1348
diff changeset
   526
findLast:aBlock startingAt:startIndex
459c00460dc0 + findLast:startingAt:endingAt:
ca
parents: 1348
diff changeset
   527
    "Return the index of the last association in the dictionary for which aBlock
459c00460dc0 + findLast:startingAt:endingAt:
ca
parents: 1348
diff changeset
   528
     evaluates as true. Start the search at startIndex.
459c00460dc0 + findLast:startingAt:endingAt:
ca
parents: 1348
diff changeset
   529
     If the block does not evaluate to true, return 0"
459c00460dc0 + findLast:startingAt:endingAt:
ca
parents: 1348
diff changeset
   530
459c00460dc0 + findLast:startingAt:endingAt:
ca
parents: 1348
diff changeset
   531
    startIndex to:1 by:-1 do: [:index | 
459c00460dc0 + findLast:startingAt:endingAt:
ca
parents: 1348
diff changeset
   532
        (aBlock value:(self associationAt:(order at:index))) ifTrue: [^ index]
459c00460dc0 + findLast:startingAt:endingAt:
ca
parents: 1348
diff changeset
   533
    ].
459c00460dc0 + findLast:startingAt:endingAt:
ca
parents: 1348
diff changeset
   534
    ^ 0
459c00460dc0 + findLast:startingAt:endingAt:
ca
parents: 1348
diff changeset
   535
!
459c00460dc0 + findLast:startingAt:endingAt:
ca
parents: 1348
diff changeset
   536
459c00460dc0 + findLast:startingAt:endingAt:
ca
parents: 1348
diff changeset
   537
findLast:aBlock startingAt:startIndex endingAt:endIndex
459c00460dc0 + findLast:startingAt:endingAt:
ca
parents: 1348
diff changeset
   538
    "Return the index of the last association in the dictionary for which aBlock
459c00460dc0 + findLast:startingAt:endingAt:
ca
parents: 1348
diff changeset
   539
     evaluates as true. Start the search at startIndex.
459c00460dc0 + findLast:startingAt:endingAt:
ca
parents: 1348
diff changeset
   540
     End the search at endIndex or when an element is found.
459c00460dc0 + findLast:startingAt:endingAt:
ca
parents: 1348
diff changeset
   541
     If the block does not evaluate to true, return 0"
459c00460dc0 + findLast:startingAt:endingAt:
ca
parents: 1348
diff changeset
   542
459c00460dc0 + findLast:startingAt:endingAt:
ca
parents: 1348
diff changeset
   543
    startIndex to:endIndex by:-1 do: [:index | 
459c00460dc0 + findLast:startingAt:endingAt:
ca
parents: 1348
diff changeset
   544
        (aBlock value:(self associationAt:(order at:index))) ifTrue: [^ index]
459c00460dc0 + findLast:startingAt:endingAt:
ca
parents: 1348
diff changeset
   545
    ].
459c00460dc0 + findLast:startingAt:endingAt:
ca
parents: 1348
diff changeset
   546
    ^ 0
459c00460dc0 + findLast:startingAt:endingAt:
ca
parents: 1348
diff changeset
   547
!
459c00460dc0 + findLast:startingAt:endingAt:
ca
parents: 1348
diff changeset
   548
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   549
from:firstIndex to:lastIndex do: aBlock
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   550
    "Evaluate aBlock with each of the dictionary's associations from index 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   551
    firstIndex to index secondIndex as the argument."
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   552
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   553
    order from:firstIndex to:lastIndex do:[:key |
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   554
        aBlock value: (self at:key)
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   555
    ].
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   556
!
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   557
835
180efa0787ce checkin from browser
Claus Gittinger <cg@exept.de>
parents: 775
diff changeset
   558
keysAndValuesDo:aBlock
180efa0787ce checkin from browser
Claus Gittinger <cg@exept.de>
parents: 775
diff changeset
   559
    "perform the block for all keys in the collection.
180efa0787ce checkin from browser
Claus Gittinger <cg@exept.de>
parents: 775
diff changeset
   560
180efa0787ce checkin from browser
Claus Gittinger <cg@exept.de>
parents: 775
diff changeset
   561
     See also:
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   562
        #associationsDo:   (which passes key-value associations)
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   563
        #keysAndValuesDo:  (which passes keys & values separately)
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   564
        #do:               (which passes values only)
835
180efa0787ce checkin from browser
Claus Gittinger <cg@exept.de>
parents: 775
diff changeset
   565
180efa0787ce checkin from browser
Claus Gittinger <cg@exept.de>
parents: 775
diff changeset
   566
     WARNING: do not add/remove elements while iterating over the receiver.
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   567
              Iterate over a copy to do this."
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   568
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   569
    order do: [:key | aBlock value:key value:(self at: key)].
835
180efa0787ce checkin from browser
Claus Gittinger <cg@exept.de>
parents: 775
diff changeset
   570
180efa0787ce checkin from browser
Claus Gittinger <cg@exept.de>
parents: 775
diff changeset
   571
    "Modified: / 26.6.1999 / 10:55:30 / ps"
180efa0787ce checkin from browser
Claus Gittinger <cg@exept.de>
parents: 775
diff changeset
   572
    "Created: / 15.10.1999 / 16:49:31 / cg"
180efa0787ce checkin from browser
Claus Gittinger <cg@exept.de>
parents: 775
diff changeset
   573
    "Modified: / 15.10.1999 / 16:53:50 / cg"
180efa0787ce checkin from browser
Claus Gittinger <cg@exept.de>
parents: 775
diff changeset
   574
!
180efa0787ce checkin from browser
Claus Gittinger <cg@exept.de>
parents: 775
diff changeset
   575
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   576
keysDo:aBlock
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   577
    "perform the block for all keys in the collection.
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   578
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   579
     See also:
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   580
        #associationsDo:   (which passes key-value associations)
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   581
        #keysAndValuesDo:  (which passes keys & values separately)
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   582
        #do:               (which passes values only)
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   583
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   584
     WARNING: do not add/remove elements while iterating over the receiver.
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   585
              Iterate over a copy to do this."
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   586
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   587
    order do:[:key | aBlock value:key].
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   588
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   589
    "Created: / 26.6.1999 / 10:53:00 / ps"
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   590
    "Modified: / 26.6.1999 / 10:55:30 / ps"
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   591
!
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   592
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   593
reverse
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   594
    "Destructively reverse my order.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   595
     WARNING: this is a destructive operation, which modifies the receiver."
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   596
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   597
    order reverse
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   598
!
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   599
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   600
reverseDo: aBlock 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   601
    "Evaluate aBlock with each of the dictionary's associations as the argument,
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   602
    starting with the last element and taking each in sequence up to the first."
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   603
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   604
    order size to:1 by:-1 do: [:index | 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   605
        aBlock value:(self associationAt:(order at:index))
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   606
    ]
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   607
!
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   608
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   609
reversed
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   610
    "Return with a new OrderedDictionary with its associations in reverse order."
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   611
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   612
    | newDict|
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   613
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   614
    newDict := OrderedDictionary new.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   615
    order size to:1 by:-1 do:[:index | 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   616
        |key|
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   617
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   618
        key := order at:index.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   619
        newDict at:key put:(self at:key)
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   620
    ].
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   621
    ^ newDict
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   622
!
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   623
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   624
select:aBlock 
1589
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   625
    "Evaluate aBlock with each of the dictionary's values as the argument.
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   626
     Collect into a new OrderedDictionary only those associations for which 
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   627
     aBlock evaluated to true. Return the new OrderedDictionary."
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   628
1589
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   629
    |newColl|
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   630
1589
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   631
    newColl := self species new.
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   632
    order do:[:key | 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   633
        |assoc|
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   634
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   635
        assoc := self associationAt:key.
1589
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   636
        (aBlock value:(assoc value)) ifTrue: [
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   637
            newColl add:assoc
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   638
        ]
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   639
    ].
1589
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   640
    ^ newColl
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   641
! !
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   642
1571
fa44f16fd6cd proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
   643
!OrderedDictionary methodsFor:'initialization'!
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   644
1571
fa44f16fd6cd proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
   645
initializeOrder
fa44f16fd6cd proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
   646
        order := OrderedCollection new
fa44f16fd6cd proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
   647
! !
fa44f16fd6cd proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
   648
fa44f16fd6cd proper #initialize
Claus Gittinger <cg@exept.de>
parents: 1444
diff changeset
   649
!OrderedDictionary methodsFor:'private'!
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   650
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   651
removeFromOrder: aKey 
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   652
	order remove: aKey ifAbsent: []
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   653
! !
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   654
120
fa3590433788 New methods for SequencableCollection access.
Stefan Vogel <sv@exept.de>
parents: 67
diff changeset
   655
!OrderedDictionary methodsFor:'removing'!
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   656
775
aafd903af15e added #removeKey: and #removeFirst.
Claus Gittinger <cg@exept.de>
parents: 757
diff changeset
   657
removeFirst
aafd903af15e added #removeKey: and #removeFirst.
Claus Gittinger <cg@exept.de>
parents: 757
diff changeset
   658
    |key|
aafd903af15e added #removeKey: and #removeFirst.
Claus Gittinger <cg@exept.de>
parents: 757
diff changeset
   659
aafd903af15e added #removeKey: and #removeFirst.
Claus Gittinger <cg@exept.de>
parents: 757
diff changeset
   660
    order size == 0 ifTrue:[
838
9454fd75930e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   661
	"error if collection is empty"
775
aafd903af15e added #removeKey: and #removeFirst.
Claus Gittinger <cg@exept.de>
parents: 757
diff changeset
   662
838
9454fd75930e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 835
diff changeset
   663
	^ self emptyCollectionError.
775
aafd903af15e added #removeKey: and #removeFirst.
Claus Gittinger <cg@exept.de>
parents: 757
diff changeset
   664
    ].
aafd903af15e added #removeKey: and #removeFirst.
Claus Gittinger <cg@exept.de>
parents: 757
diff changeset
   665
    key := order removeFirst.
aafd903af15e added #removeKey: and #removeFirst.
Claus Gittinger <cg@exept.de>
parents: 757
diff changeset
   666
    ^ super removeKey:key.
aafd903af15e added #removeKey: and #removeFirst.
Claus Gittinger <cg@exept.de>
parents: 757
diff changeset
   667
!
aafd903af15e added #removeKey: and #removeFirst.
Claus Gittinger <cg@exept.de>
parents: 757
diff changeset
   668
120
fa3590433788 New methods for SequencableCollection access.
Stefan Vogel <sv@exept.de>
parents: 67
diff changeset
   669
removeFromIndex:fromIndex toIndex:toIndex
fa3590433788 New methods for SequencableCollection access.
Stefan Vogel <sv@exept.de>
parents: 67
diff changeset
   670
    | keys |
fa3590433788 New methods for SequencableCollection access.
Stefan Vogel <sv@exept.de>
parents: 67
diff changeset
   671
fa3590433788 New methods for SequencableCollection access.
Stefan Vogel <sv@exept.de>
parents: 67
diff changeset
   672
    keys := order copyFrom:fromIndex to:toIndex.
fa3590433788 New methods for SequencableCollection access.
Stefan Vogel <sv@exept.de>
parents: 67
diff changeset
   673
    order removeFromIndex:fromIndex toIndex:toIndex.
fa3590433788 New methods for SequencableCollection access.
Stefan Vogel <sv@exept.de>
parents: 67
diff changeset
   674
    keys do:[ :key |
fa3590433788 New methods for SequencableCollection access.
Stefan Vogel <sv@exept.de>
parents: 67
diff changeset
   675
	super removeKey:key.
fa3590433788 New methods for SequencableCollection access.
Stefan Vogel <sv@exept.de>
parents: 67
diff changeset
   676
    ].
fa3590433788 New methods for SequencableCollection access.
Stefan Vogel <sv@exept.de>
parents: 67
diff changeset
   677
fa3590433788 New methods for SequencableCollection access.
Stefan Vogel <sv@exept.de>
parents: 67
diff changeset
   678
    "Created: 28.9.1995 / 12:04:33 / stefan"
775
aafd903af15e added #removeKey: and #removeFirst.
Claus Gittinger <cg@exept.de>
parents: 757
diff changeset
   679
!
aafd903af15e added #removeKey: and #removeFirst.
Claus Gittinger <cg@exept.de>
parents: 757
diff changeset
   680
aafd903af15e added #removeKey: and #removeFirst.
Claus Gittinger <cg@exept.de>
parents: 757
diff changeset
   681
removeKey:aKey
aafd903af15e added #removeKey: and #removeFirst.
Claus Gittinger <cg@exept.de>
parents: 757
diff changeset
   682
    order remove:aKey.
aafd903af15e added #removeKey: and #removeFirst.
Claus Gittinger <cg@exept.de>
parents: 757
diff changeset
   683
    ^ super removeKey:aKey.
1444
d84641232d2a +removeLast
werner
parents: 1424
diff changeset
   684
!
d84641232d2a +removeLast
werner
parents: 1424
diff changeset
   685
d84641232d2a +removeLast
werner
parents: 1424
diff changeset
   686
removeLast
d84641232d2a +removeLast
werner
parents: 1424
diff changeset
   687
    |key|
d84641232d2a +removeLast
werner
parents: 1424
diff changeset
   688
d84641232d2a +removeLast
werner
parents: 1424
diff changeset
   689
    order size == 0 ifTrue:[
d84641232d2a +removeLast
werner
parents: 1424
diff changeset
   690
	"error if collection is empty"
d84641232d2a +removeLast
werner
parents: 1424
diff changeset
   691
d84641232d2a +removeLast
werner
parents: 1424
diff changeset
   692
	^ self emptyCollectionError.
d84641232d2a +removeLast
werner
parents: 1424
diff changeset
   693
    ].
d84641232d2a +removeLast
werner
parents: 1424
diff changeset
   694
    key := order removeLast.
d84641232d2a +removeLast
werner
parents: 1424
diff changeset
   695
    ^ super removeKey:key.
120
fa3590433788 New methods for SequencableCollection access.
Stefan Vogel <sv@exept.de>
parents: 67
diff changeset
   696
! !
fa3590433788 New methods for SequencableCollection access.
Stefan Vogel <sv@exept.de>
parents: 67
diff changeset
   697
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   698
!OrderedDictionary methodsFor:'searching'!
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   699
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   700
identityIndexOfAssociation: anAssociation 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   701
    "Return the identity index of anAssociation within the receiver. If the receiver
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   702
    does not contain anAssociation, return 0."
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   703
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   704
    ^ self identityIndexOfAssociation: anAssociation ifAbsent: [0]
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   705
!
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   706
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   707
identityIndexOfAssociation: anAssociation ifAbsent: exceptionBlock 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   708
    "Return the identity index of anAssociation within the receiver. 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   709
     If the receiver does not contain anAssociation, 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   710
     return the result of evaluating the exceptionBlock."
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   711
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   712
    "/ as ST/X's dictionaries do not store the associations 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   713
    "/ (instead, they store the keys and values in separate collections)
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   714
    "/ this will not work. You have to think about it and rewrite your code.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   715
    self error:'this does not work in Smalltalk/X'.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   716
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   717
    order keysAndValuesDo:[:i :key |
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   718
        (self associationAt:key) == anAssociation ifTrue: [^i]
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   719
    ].
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   720
    ^exceptionBlock value
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   721
!
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   722
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   723
identityIndexOfKey: aKey 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   724
    "Return the identity index of aKey within the receiver. If the receiver 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   725
    does not contain aKey, return 0."
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   726
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   727
    ^self identityIndexOfKey: aKey ifAbsent: [0]
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   728
!
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   729
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   730
identityIndexOfKey: aKey ifAbsent: exceptionBlock 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   731
    "Return the identity index of aKey within the receiver.  If the receiver does
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   732
    not contain aKey, return the result of evaluating the exceptionBlock."
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   733
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   734
    ^ order identityIndexOf:aKey ifAbsent:exceptionBlock
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   735
!
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   736
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   737
identityIndexOfValue: aValue 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   738
    "Return the identity index of aValue within the receiver. If the receiver 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   739
    does not contain aValue, return 0."
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   740
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   741
    ^self identityIndexOfValue: aValue ifAbsent: [0]
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   742
!
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   743
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   744
identityIndexOfValue: aValue ifAbsent: exceptionBlock 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   745
    "Return the identity index of aValue within the receiver. If the receiver 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   746
    does not contain aValue, return the result of evaluating the exceptionBlock."
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   747
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   748
    order keysAndValuesDo:[:i :key | (self at:key) == aValue ifTrue: [^i]].
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   749
    ^exceptionBlock value
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   750
!
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   751
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   752
indexOfAssociation: anAssociation 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   753
    "Return the index of anAssociation within the receiver. If the receiver does
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   754
    not contain anAssociation, return 0."
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   755
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   756
    ^self indexOfAssociation: anAssociation ifAbsent: [0]
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   757
!
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   758
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   759
indexOfAssociation: anAssociation ifAbsent: exceptionBlock 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   760
    "Return the identity index of anAssociation within the receiver. If the receiver
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   761
    does not contain anAssociation, return the result of evaluating the exceptionBlock."
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   762
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   763
    order keysAndValuesDo:[:i :key | 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   764
        (self associationAt:key) = anAssociation ifTrue: [^i]
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   765
    ].
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   766
    ^exceptionBlock value
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   767
!
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   768
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   769
indexOfKey: aKey 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   770
    "Return the index of aKey within the receiver. If the receiver does 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   771
     not contain aKey, return 0."
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   772
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   773
    ^self indexOfKey: aKey ifAbsent: [0]
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   774
!
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   775
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   776
indexOfKey: aKey ifAbsent: exceptionBlock 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   777
    "Return the identity index of aKey within the receiver.  If the receiver does
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   778
     not contain aKey, return the result of evaluating the exceptionBlock."
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   779
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   780
    ^ order indexOf:aKey ifAbsent:exceptionBlock
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   781
!
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   782
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   783
indexOfValue: aValue 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   784
    "Return the index of aValue within the receiver. 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   785
     If the receiver does not contain aValue, return 0."
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   786
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   787
    ^self indexOfValue: aValue ifAbsent: [0]
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   788
!
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   789
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   790
indexOfValue: aValue ifAbsent: exceptionBlock 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   791
    "Return the identity index of aValue within the receiver. 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   792
     If the receiver does not contain aValue, return the result of evaluating the exceptionBlock."
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   793
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   794
    order keysAndValuesDo:[:i :key | (self at:key) = aValue ifTrue: [^i]].
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   795
    ^ exceptionBlock value
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   796
!
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   797
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   798
nextIndexOfAssociation: aAssociation from: startIndex to: stopIndex 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   799
    "Return the next index of aAssociation within the receiver between startIndex
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   800
     and stopIndex. If the receiver does not contain aAssociation, return nil"
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   801
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   802
    startIndex to: stopIndex do: [:i | 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   803
        (self associationAt: (order at: i)) = aAssociation ifTrue: [^i]].
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   804
    ^nil
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   805
!
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   806
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   807
nextIndexOfKey: aKey from: startIndex to: stopIndex 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   808
    "Return the next index of aKey within the receiver between startIndex and 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   809
     stopIndex.  If the receiver does not contain aKey, return nil"
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   810
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   811
    startIndex to: stopIndex do: [:i | 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   812
        (order at: i) = aKey ifTrue: [^i]].
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   813
    ^nil
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   814
!
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   815
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   816
nextIndexOfValue: aValue from: startIndex to: stopIndex 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   817
    "Return the next index of aValue within the receiver between startIndex and
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   818
     stopIndex. If the receiver does not contain aValue, return nil"
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   819
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   820
    startIndex to: stopIndex do: [:i | 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   821
        (self at: (order at: i)) = aValue ifTrue: [^i]].
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   822
    ^nil
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   823
!
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   824
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   825
prevIndexOfAssociation: aAssociation from: startIndex to: stopIndex 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   826
    "Return the previous index of aAssociation within the receiver between 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   827
     startIndex  and stopIndex working backwards through the receiver. 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   828
     If the receiver does not contain aAssociation, return nil"
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   829
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   830
    startIndex to: stopIndex by: -1
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   831
            do: [:i | (self associationAt: (order at: i)) = aAssociation ifTrue: [^i]].
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   832
    ^nil
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   833
!
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   834
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   835
prevIndexOfKey: aKey from: startIndex to: stopIndex 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   836
    "Return the previous index of aKey within the receiver between startIndex and
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   837
     stopIndex working backwards through the receiver. 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   838
     If the receiver does not contain aKey, return nil"
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   839
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   840
    startIndex to: stopIndex by: -1
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   841
            do: [:i | (order at: i) = aKey ifTrue: [^i]].
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   842
    ^nil
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   843
!
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   844
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   845
prevIndexOfValue: aValue from: startIndex to: stopIndex 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   846
    "Return the previous index of aValue within the receiver between startIndex
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   847
     and stopIndex working backwards through the receiver. 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   848
     If the receiver does not contain aValue, return nil"
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   849
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   850
    startIndex to: stopIndex by: -1
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   851
            do: [:i | 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   852
                (self at: (order at: i)) = aValue ifTrue: [^i]].
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   853
    ^nil
1130
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   854
! !
94c1def975c2 category change
Claus Gittinger <cg@exept.de>
parents: 959
diff changeset
   855
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   856
!OrderedDictionary methodsFor:'testing'!
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   857
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   858
occurrencesOfKey: aKey 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   859
    "Return how many of the dictionary's keys are equal to aKey."
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   860
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   861
    ^ order count:[:eachKey | aKey = eachKey]
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   862
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   863
"/ cg: the original code was not very smalltalkish:
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   864
"/
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   865
"/    | count |
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   866
"/
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   867
"/    count := 0.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   868
"/    1 to: self size do: [:index | aKey = (order at: index) ifTrue: [count := count + 1]].
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   869
"/    ^count
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   870
!
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   871
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   872
occurrencesOfValue: aValue 
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   873
    "Return how many of the dictionary's values are equal to aValue."
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   874
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   875
    ^ order count:[:eachKey | aValue = (self at:eachKey)]
62
a759b5c72c98 Initial revision
claus
parents:
diff changeset
   876
1242
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   877
"/ cg: the original code was not very smalltalkish:
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   878
"/
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   879
"/    | count |
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   880
"/
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   881
"/    count := 0.
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   882
"/    1 to: self size do: [:index | 
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   883
"/        aValue = (self at: (order at: index)) ifTrue: [count := count + 1]].
14de3b9cbd39 many code rewrites
Claus Gittinger <cg@exept.de>
parents: 1130
diff changeset
   884
"/    ^count
959
a481d378ccf5 add/at:put: messages return the added element
martin
parents: 885
diff changeset
   885
! !
757
84c4c41ed23f checkin from browser
ps
parents: 504
diff changeset
   886
775
aafd903af15e added #removeKey: and #removeFirst.
Claus Gittinger <cg@exept.de>
parents: 757
diff changeset
   887
!OrderedDictionary class methodsFor:'documentation'!
aafd903af15e added #removeKey: and #removeFirst.
Claus Gittinger <cg@exept.de>
parents: 757
diff changeset
   888
aafd903af15e added #removeKey: and #removeFirst.
Claus Gittinger <cg@exept.de>
parents: 757
diff changeset
   889
version
1589
f0607bf986e0 fixed collect/associationsCollect:
Claus Gittinger <cg@exept.de>
parents: 1581
diff changeset
   890
    ^ '$Header: /cvs/stx/stx/libbasic2/Attic/OrderedDictionary.st,v 1.22 2006-01-25 12:22:23 cg Exp $'
775
aafd903af15e added #removeKey: and #removeFirst.
Claus Gittinger <cg@exept.de>
parents: 757
diff changeset
   891
aafd903af15e added #removeKey: and #removeFirst.
Claus Gittinger <cg@exept.de>
parents: 757
diff changeset
   892
! !