SmallDictionary.st
author Jan Vrany <jan.vrany@labware.com>
Wed, 22 Mar 2023 13:57:18 +0000
branchjv
changeset 25445 1623217d2268
parent 24913 a8c2e208c890
child 25447 be0c3d4cdfd5
permissions -rw-r--r--
Cherry-picked OrderedCollection.st from 0b286fd51da7: * d4c86d7c0bfc: #TUNING by stefan, Stefan Vogel <sv@exept.de> * 692b6497a669: #DOCUMENTATION by stefan, Stefan Vogel <sv@exept.de> * d47bb2912953: #DOCUMENTATION by stefan, Stefan Vogel <sv@exept.de> * abb4316c6bff: #FEATURE by cg, Claus Gittinger <cg@exept.de> * 3a8fce0e8d11: #TUNING by stefan, Stefan Vogel <sv@exept.de> * 03d29bf8c5bb: #REFACTORING by stefan, Stefan Vogel <sv@exept.de> * cccc6c4abcfc: #REFACTORING by stefan, Stefan Vogel <sv@exept.de> * 35d957c7a840: #FEATURE by cg, Claus Gittinger <cg@exept.de> * 6b11890f5f2c: #OTHER by cg, Claus Gittinger <cg@exept.de> * abb6108fb06b: #FEATURE by cg, Claus Gittinger <cg@exept.de> * 2c4768bb2e89: #FEATURE by cg, Claus Gittinger <cg@exept.de> * 4029e964d0f1: #FEATURE by cg, Claus Gittinger <cg@exept.de> * ddcab3a9c2df: #OTHER by cg, Claus Gittinger <cg@exept.de> * 2213eb56e0c7: #REFACTORING by exept, Claus Gittinger <cg@exept.de> * 09ca874a6160: #REFACTORING by exept, Claus Gittinger <cg@exept.de> * 30b332af1f33: #BUGFIX by stefan, Stefan Vogel <sv@exept.de> * 779764ba117b: #REFACTORING by cg, Claus Gittinger <cg@exept.de> * b3d232a613c9: #BUGFIX by stefan, Stefan Vogel <sv@exept.de> * c417f7edaec1: #BUGFIX by stefan, Stefan Vogel <sv@exept.de> * 904b6538f379: #FEATURE by exept, Claus Gittinger <cg@exept.de> * c5887f03e01f: #REFACTORING by stefan, Stefan Vogel <sv@exept.de> * 8912d03aff48: #BUGFIX by exept, Claus Gittinger <cg@exept.de> * de5cd1dab4c3: #DOCUMENTATION by exept, Claus Gittinger <cg@exept.de> * 9bbd26603378: #OTHER by exept, Claus Gittinger <cg@exept.de> * c2c9dc110f42: #FEATURE by stefan, Stefan Vogel <sv@exept.de> * 81d123c6703d: #DOCUMENTATION by stefan, Stefan Vogel <sv@exept.de> * 8aadbb21458a: #BUGFIX by stefan, Stefan Vogel <sv@exept.de> * f210dbb8b2f6: #TUNING by stefan, Stefan Vogel <sv@exept.de> * c2c774fc53c0: #FEATURE by exept, Claus Gittinger <cg@exept.de> * b6f462670875: #DOCUMENTATION by exept, Claus Gittinger <cg@exept.de> * 27ae4021d5d6: #FEATURE by stefan, Stefan Vogel <sv@exept.de> * 10d9e9d85594: #TUNING by exept, Claus Gittinger <cg@exept.de> * 2653d855dcc7: #DOCUMENTATION by exept, Claus Gittinger <cg@exept.de> * 6ea1698a1a34: #FEATURE by stefan, Stefan Vogel <sv@exept.de> * 28762315e664: #OTHER by exept, Claus Gittinger <cg@exept.de> * 7142ea786f3e: #TUNING by stefan, Stefan Vogel <sv@exept.de> * 7875acb42b53: #BUGFIX by stefan, Stefan Vogel <sv@exept.de> * 163a0eebc97e: #BUGFIX by Maren, matilk
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24913
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
"{ Encoding: utf8 }"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
 COPYRIGHT (c) 2018 by eXept Software AG
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
              All Rights Reserved
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     6
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
 This software is furnished under a license and may be used
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
 inclusion of the above copyright notice.  This software may not
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
 hereby transferred.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    13
"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    14
"{ Package: 'stx:libbasic' }"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    16
"{ NameSpace: Smalltalk }"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
KeyedCollection subclass:#SmallDictionary
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
	instanceVariableNames:'keysAndValues tally'
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
	classVariableNames:''
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
	poolDictionaries:''
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
	category:'Collections-Unordered'
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    24
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    25
!SmallDictionary class methodsFor:'documentation'!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
copyright
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    29
 COPYRIGHT (c) 2018 by eXept Software AG
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    30
              All Rights Reserved
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
 This software is furnished under a license and may be used
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
 only in accordance with the terms of that license and with the
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
 inclusion of the above copyright notice.  This software may not
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
 be provided or otherwise made available to, or used by, any
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    36
 other person.  No title to or ownership of the software is
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    37
 hereby transferred.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    39
"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    40
!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    41
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    42
documentation
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    43
"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    44
    A lightweight Dictionary implementation (without hashing)
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    45
    for small dictionaries.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    46
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    47
    Use this, when you have to store a small number (e.g. < 20) key/value pairs.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    48
    As a side effect of the implementation, the dictionary is also ordered.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    49
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    50
    Inspired by and compatible with RBSmallDictionary from RefactoryBrowser
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    51
    (although the implementaion is different).
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    52
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    53
    [instance variables:]
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    54
        keysAndValues       Array           keys are stored at odd indices, values at even indices
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    55
        tally               SmallInterger   the number of valid key/value pairs
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    56
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    57
    [class variables:]
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    58
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    59
    [see also:]
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    60
        Dictionary
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    61
        MethodDictionary
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    62
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    63
    [author:]
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    64
        Stefan Vogel
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    65
"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    66
! !
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    67
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    68
!SmallDictionary class methodsFor:'instance creation'!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    69
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    70
new
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    71
    ^ self basicNew initialize:2
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    72
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    73
    "Modified: / 14-09-2018 / 15:58:29 / Stefan Vogel"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    74
!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    75
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    76
new:capacity 
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    77
    ^ self basicNew initialize:capacity
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    78
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    79
    "Modified: / 14-09-2018 / 15:58:49 / Stefan Vogel"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    80
! !
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    81
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    82
!SmallDictionary methodsFor:'accessing'!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    83
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    84
at:key ifAbsent:aBlock 
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    85
    "return the element indexed by aKey -
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    86
     return result of exceptionBlock if no element is stored under aKey"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    87
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    88
    |keyIndex "{Class: SmallInteger}"|
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    89
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    90
    keyIndex := keysAndValues indexOf:key startingAt:1 step:2.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    91
    ^ keyIndex == 0 ifTrue:[aBlock value] ifFalse:[keysAndValues basicAt:keyIndex+1]
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    92
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    93
    "Modified: / 18-09-2018 / 14:08:21 / Stefan Vogel"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    94
!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    95
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    96
at:key ifAbsentPut:aBlock 
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    97
    "return the element indexed by aKey if present,
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    98
     if not present, store the result of evaluating valueBlock
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    99
     under aKey and return it.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   100
     WARNING: do not add elements while iterating over the receiver.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   101
              Iterate over a copy to do this."
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   102
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   103
    |keyIndex|
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   104
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   105
    keyIndex := keysAndValues indexOf:key startingAt:1 step:2.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   106
    keyIndex == 0 ifTrue:[
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   107
        ^ self privateAt:key put:aBlock value
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   108
    ] ifFalse:[
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   109
        ^ keysAndValues basicAt:keyIndex+1.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   110
    ]
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   111
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   112
    "Modified: / 18-09-2018 / 14:08:26 / Stefan Vogel"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   113
!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   114
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   115
keys
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   116
    "return a collection containing the keys of the receiver"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   117
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   118
    |keys sz "{Class: SmallInteger}"|
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   119
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   120
    keys := Array new:tally.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   121
    sz := tally.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   122
    1 to:sz do:[:i | keys at:i put:(keysAndValues at:i*2-1)].
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   123
    ^ keys
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   124
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   125
    "Created: / 14-09-2018 / 17:35:25 / Stefan Vogel"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   126
!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   127
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   128
order
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   129
    "returns the keys in the order of their appearance"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   130
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   131
    ^ self keys
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   132
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   133
    "
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   134
     |s|
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   135
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   136
     s := SmallDictionary new.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   137
     s at:#a put:'aaa'; at:#b put:'bbb'; at:#c put:'ccc'; at:#d put:'ddd'; at:#a put:'aaaa'.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   138
     s order    
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   139
    "
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   140
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   141
    "Created: / 14-09-2018 / 17:30:44 / Stefan Vogel"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   142
!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   143
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   144
size
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   145
    "return the number of elements in the receiver."
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   146
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   147
    ^ tally
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   148
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   149
    "Modified (format): / 14-09-2018 / 15:44:11 / Stefan Vogel"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   150
! !
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   151
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   152
!SmallDictionary methodsFor:'adding'!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   153
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   154
add:anAssociation 
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   155
    "add the argument, anAssociation to the receiver.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   156
     Returns the argument, anAssociation.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   157
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   158
     WARNING: do not add elements while iterating over the receiver.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   159
              Iterate over a copy to do this."
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   160
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   161
    self at:anAssociation key put:anAssociation value.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   162
    ^ anAssociation
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   163
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   164
    "Modified (format): / 14-09-2018 / 15:25:38 / Stefan Vogel"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   165
!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   166
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   167
at:key put:value 
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   168
    "add the argument anObject under key, aKey to the receiver.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   169
     Return anObject (sigh).
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   170
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   171
     WARNING: do not add elements while iterating over the receiver.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   172
              Iterate over a copy to do this."
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   173
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   174
    |keyIndex|
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   175
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   176
    "/ specially tuned for single-element small dicts (most are)
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   177
    tally == 0 ifTrue:[
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   178
        keysAndValues size >= 2 ifTrue:[
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   179
            keysAndValues basicAt:1 put:key.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   180
            keysAndValues basicAt:2 put:value.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   181
            tally := 1.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   182
            ^ self.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   183
        ].
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   184
    ].
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   185
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   186
    keyIndex := keysAndValues indexOf:key startingAt:1 step:2.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   187
    keyIndex == 0 ifTrue:[
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   188
        self privateAt:key put:value
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   189
    ] ifFalse:[
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   190
        keysAndValues basicAt:keyIndex+1 put:value.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   191
    ].
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   192
    ^ value
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   193
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   194
    "Modified: / 18-09-2018 / 14:12:13 / Stefan Vogel"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   195
! !
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   196
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   197
!SmallDictionary methodsFor:'copying-private'!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   198
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   199
postCopy
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   200
    keysAndValues := keysAndValues copy.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   201
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   202
    "Modified: / 14-09-2018 / 15:38:50 / Stefan Vogel"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   203
! !
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   204
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   205
!SmallDictionary methodsFor:'enumerating'!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   206
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   207
do:aBlock
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   208
    "enumerate the values"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   209
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   210
    |sz "{Class: SmallInteger}"|
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   211
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   212
    sz := tally * 2.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   213
    2 to:sz by:2 do:[:i | aBlock value:(keysAndValues at:i)]
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   214
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   215
    "Modified: / 14-09-2018 / 16:30:18 / Stefan Vogel"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   216
!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   217
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   218
keysAndValuesDo:aBlock 
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   219
    |sz "{Class: SmallInteger}"|
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   220
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   221
    sz := tally * 2.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   222
    1 to:sz-1 by:2 do:[:i | 
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   223
        aBlock 
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   224
            value:(keysAndValues at:i) 
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   225
            value:(keysAndValues at:i+1)]
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   226
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   227
    "Modified: / 14-09-2018 / 16:31:18 / Stefan Vogel"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   228
!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   229
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   230
keysDo:aBlock 
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   231
    |sz "{Class: SmallInteger}"|
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   232
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   233
    sz := tally * 2.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   234
    1 to:sz-1 by:2 do:[:i | aBlock value:(keysAndValues at:i)]
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   235
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   236
    "Modified: / 14-09-2018 / 16:30:51 / Stefan Vogel"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   237
! !
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   238
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   239
!SmallDictionary methodsFor:'initialize-release'!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   240
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   241
initialize:capacity
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   242
    keysAndValues := Array new:capacity*2.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   243
    tally := 0
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   244
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   245
    "Created: / 14-09-2018 / 15:57:42 / Stefan Vogel"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   246
! !
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   247
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   248
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   249
!SmallDictionary methodsFor:'private'!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   250
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   251
grow:capacity 
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   252
    |newKeysAndValues|
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   253
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   254
    newKeysAndValues := Array new:capacity*2.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   255
    newKeysAndValues replaceFrom:1 to:tally * 2 with:keysAndValues.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   256
    keysAndValues := newKeysAndValues.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   257
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   258
    "Created: / 18-09-2018 / 15:37:24 / Stefan Vogel"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   259
!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   260
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   261
growKeysAndValues
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   262
    "duplicate the capacity"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   263
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   264
    self grow:tally * 2
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   265
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   266
    "Modified: / 18-09-2018 / 15:37:34 / Stefan Vogel"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   267
!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   268
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   269
privateAt:key put:value
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   270
    |sz "{Class: SmallInteger}"|
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   271
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   272
    sz := tally * 2.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   273
    sz == keysAndValues size ifTrue: [self growKeysAndValues].
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   274
    keysAndValues 
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   275
        basicAt:sz+1 put:key;
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   276
        basicAt:sz+2 put:value.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   277
    tally := tally + 1.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   278
    ^ value.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   279
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   280
    "Modified: / 18-09-2018 / 13:33:30 / Stefan Vogel"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   281
! !
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   282
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   283
!SmallDictionary methodsFor:'queries'!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   284
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   285
includesKey:aKey 
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   286
    ^ (keysAndValues indexOf:aKey startingAt:1 step:2) ~~ 0
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   287
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   288
    "Modified: / 18-09-2018 / 14:09:03 / Stefan Vogel"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   289
!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   290
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   291
isEmpty
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   292
    ^ tally == 0
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   293
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   294
    "Created: / 14-09-2018 / 15:44:49 / Stefan Vogel"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   295
!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   296
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   297
speciesForCollecting
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   298
    ^ Bag
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   299
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   300
    "Created: / 18-09-2018 / 15:34:27 / Stefan Vogel"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   301
! !
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   302
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   303
!SmallDictionary methodsFor:'removing'!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   304
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   305
empty
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   306
    "RefactoryBrowser compatibility"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   307
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   308
    self removeAll
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   309
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   310
    "Modified: / 14-09-2018 / 15:59:57 / Stefan Vogel"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   311
!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   312
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   313
remove:anAssociation ifAbsent:anExceptionBlock 
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   314
    self removeKey:(anAssociation key) ifAbsent:anExceptionBlock.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   315
    ^ anAssociation
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   316
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   317
    "Modified (format): / 14-09-2018 / 15:40:44 / Stefan Vogel"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   318
!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   319
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   320
removeAll
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   321
    tally := 0.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   322
    keysAndValues atAllPut:nil.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   323
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   324
    "Modified: / 14-09-2018 / 16:02:28 / Stefan Vogel"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   325
!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   326
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   327
removeKey:key ifAbsent:aBlock 
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   328
    |keyIndex "{Class:SmallInteger}"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   329
     sz "{Class:SmallInteger}"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   330
     value|
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   331
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   332
    keyIndex := keysAndValues indexOf:key startingAt:1 step:2.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   333
    keyIndex == 0 ifTrue:[
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   334
        ^ aBlock value
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   335
    ].
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   336
    value := keysAndValues at:keyIndex+1.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   337
    sz := tally*2.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   338
    keyIndex to:sz-2 do:[:i | 
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   339
        keysAndValues at:i put:(keysAndValues at:i + 2).
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   340
    ].
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   341
    keysAndValues at:sz-1 put:nil.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   342
    keysAndValues at:sz put:nil.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   343
    tally := tally - 1.
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   344
    ^ value
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   345
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   346
    "Modified: / 18-09-2018 / 14:09:15 / Stefan Vogel"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   347
! !
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   348
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   349
!SmallDictionary methodsFor:'testing'!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   350
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   351
isDictionary
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   352
    "return true, if the receiver is some kind of dictionary;
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   353
     true returned here - the method is redefined from Object."
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   354
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   355
    ^ true
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   356
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   357
    "Created: / 14-09-2018 / 18:31:24 / Stefan Vogel"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   358
!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   359
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   360
isFixedSize
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   361
    "return true if the receiver cannot grow - this will vanish once
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   362
     Arrays and Strings learn how to grow ..."
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   363
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   364
    ^ false
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   365
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   366
    "Created: / 18-09-2018 / 15:35:25 / Stefan Vogel"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   367
! !
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   368
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   369
!SmallDictionary methodsFor:'visiting'!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   370
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   371
acceptVisitor:aVisitor with:aParameter
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   372
    "dispatch for visitor pattern; send #visitDictionary:with: to aVisitor"
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   373
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   374
    ^ aVisitor visitDictionary:self with:aParameter
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   375
! !
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   376
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   377
!SmallDictionary class methodsFor:'documentation'!
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   378
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   379
version_CVS
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   380
    ^ '$Header$'
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   381
! !
a8c2e208c890 Cherry picked `SmallDictionary` from eXept's head.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   382