CacheDictionary.st
author Claus Gittinger <cg@exept.de>
Sat, 02 May 2020 21:40:13 +0200
changeset 5476 7355a4b11cb6
parent 4843 49f5a601dee9
permissions -rw-r--r--
#FEATURE by cg class: Socket class added: #newTCPclientToHost:port:domain:domainOrder:withTimeout: changed: #newTCPclientToHost:port:domain:withTimeout:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4673
9a0b7710fe9d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4141
diff changeset
     1
"{ Encoding: utf8 }"
9a0b7710fe9d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4141
diff changeset
     2
2
07d9ee98e092 *** empty log message ***
claus
parents: 0
diff changeset
     3
"
07d9ee98e092 *** empty log message ***
claus
parents: 0
diff changeset
     4
 COPYRIGHT (c) 1993 by Claus Gittinger
84
claus
parents: 80
diff changeset
     5
	      All Rights Reserved
2
07d9ee98e092 *** empty log message ***
claus
parents: 0
diff changeset
     6
07d9ee98e092 *** empty log message ***
claus
parents: 0
diff changeset
     7
 This software is furnished under a license and may be used
07d9ee98e092 *** empty log message ***
claus
parents: 0
diff changeset
     8
 only in accordance with the terms of that license and with the
07d9ee98e092 *** empty log message ***
claus
parents: 0
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
07d9ee98e092 *** empty log message ***
claus
parents: 0
diff changeset
    10
 be provided or otherwise made available to, or used by, any
07d9ee98e092 *** empty log message ***
claus
parents: 0
diff changeset
    11
 other person.  No title to or ownership of the software is
07d9ee98e092 *** empty log message ***
claus
parents: 0
diff changeset
    12
 hereby transferred.
07d9ee98e092 *** empty log message ***
claus
parents: 0
diff changeset
    13
"
910
af28d492d1eb examples
Claus Gittinger <cg@exept.de>
parents: 538
diff changeset
    14
"{ Package: 'stx:libbasic2' }"
af28d492d1eb examples
Claus Gittinger <cg@exept.de>
parents: 538
diff changeset
    15
3461
f4ff6526ac02 renamed the private emptyCheck of Set & Dictionary
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
    16
"{ NameSpace: Smalltalk }"
f4ff6526ac02 renamed the private emptyCheck of Set & Dictionary
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
    17
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
    18
Dictionary subclass:#CacheDictionary
238
5cd00f81c000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 134
diff changeset
    19
	instanceVariableNames:''
5cd00f81c000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 134
diff changeset
    20
	classVariableNames:''
5cd00f81c000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 134
diff changeset
    21
	poolDictionaries:''
5cd00f81c000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 134
diff changeset
    22
	category:'Collections-Unordered'
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
    23
!
1cf8d1747859 Initial revision
claus
parents:
diff changeset
    24
31
e223f3cf2995 *** empty log message ***
claus
parents: 13
diff changeset
    25
!CacheDictionary class methodsFor:'documentation'!
e223f3cf2995 *** empty log message ***
claus
parents: 13
diff changeset
    26
e223f3cf2995 *** empty log message ***
claus
parents: 13
diff changeset
    27
copyright
e223f3cf2995 *** empty log message ***
claus
parents: 13
diff changeset
    28
"
e223f3cf2995 *** empty log message ***
claus
parents: 13
diff changeset
    29
 COPYRIGHT (c) 1993 by Claus Gittinger
84
claus
parents: 80
diff changeset
    30
	      All Rights Reserved
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
    31
31
e223f3cf2995 *** empty log message ***
claus
parents: 13
diff changeset
    32
 This software is furnished under a license and may be used
e223f3cf2995 *** empty log message ***
claus
parents: 13
diff changeset
    33
 only in accordance with the terms of that license and with the
e223f3cf2995 *** empty log message ***
claus
parents: 13
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
e223f3cf2995 *** empty log message ***
claus
parents: 13
diff changeset
    35
 be provided or otherwise made available to, or used by, any
e223f3cf2995 *** empty log message ***
claus
parents: 13
diff changeset
    36
 other person.  No title to or ownership of the software is
e223f3cf2995 *** empty log message ***
claus
parents: 13
diff changeset
    37
 hereby transferred.
e223f3cf2995 *** empty log message ***
claus
parents: 13
diff changeset
    38
"
e223f3cf2995 *** empty log message ***
claus
parents: 13
diff changeset
    39
!
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
    40
31
e223f3cf2995 *** empty log message ***
claus
parents: 13
diff changeset
    41
documentation
e223f3cf2995 *** empty log message ***
claus
parents: 13
diff changeset
    42
"
4141
e25ce4d8fbab #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4024
diff changeset
    43
    a CacheDictionary is a Dictionary which will not grow beyond a given max. size
e25ce4d8fbab #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4024
diff changeset
    44
    - i.e. keep only a limited number of elements.
31
e223f3cf2995 *** empty log message ***
claus
parents: 13
diff changeset
    45
    It can be used as a cache, for keeping recently used objects alive.
4141
e25ce4d8fbab #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4024
diff changeset
    46
    Must be created with an initial (=maximal) size. 
e25ce4d8fbab #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4024
diff changeset
    47
    I.e. (CacheDictionary new:100)
254
cccfa2590e6e documentation
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
    48
4141
e25ce4d8fbab #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4024
diff changeset
    49
    [see also:]
e25ce4d8fbab #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4024
diff changeset
    50
        Dictionary
e25ce4d8fbab #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4024
diff changeset
    51
        OrderedCollection
e25ce4d8fbab #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4024
diff changeset
    52
        OrderedDictionary
e25ce4d8fbab #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4024
diff changeset
    53
        
254
cccfa2590e6e documentation
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
    54
    [author:]
cccfa2590e6e documentation
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
    55
        Claus Gittinger
31
e223f3cf2995 *** empty log message ***
claus
parents: 13
diff changeset
    56
"
538
9cffa21b8dd4 added example
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
    57
!
9cffa21b8dd4 added example
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
    58
9cffa21b8dd4 added example
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
    59
examples
9cffa21b8dd4 added example
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
    60
"
910
af28d492d1eb examples
Claus Gittinger <cg@exept.de>
parents: 538
diff changeset
    61
                                                                        [exBegin]
538
9cffa21b8dd4 added example
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
    62
    |d|
9cffa21b8dd4 added example
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
    63
9cffa21b8dd4 added example
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
    64
    d := CacheDictionary new:16.
9cffa21b8dd4 added example
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
    65
    1 to:20 do:[:i |
910
af28d492d1eb examples
Claus Gittinger <cg@exept.de>
parents: 538
diff changeset
    66
        d at:i printString put:i.
538
9cffa21b8dd4 added example
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
    67
    ].
9cffa21b8dd4 added example
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
    68
    21 to:40 do:[:i |
910
af28d492d1eb examples
Claus Gittinger <cg@exept.de>
parents: 538
diff changeset
    69
        d at:i printString put:i.
538
9cffa21b8dd4 added example
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
    70
    ].
9cffa21b8dd4 added example
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
    71
    d inspect
910
af28d492d1eb examples
Claus Gittinger <cg@exept.de>
parents: 538
diff changeset
    72
                                                                        [exEnd]
538
9cffa21b8dd4 added example
Claus Gittinger <cg@exept.de>
parents: 499
diff changeset
    73
"
31
e223f3cf2995 *** empty log message ***
claus
parents: 13
diff changeset
    74
! !
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
    75
1cf8d1747859 Initial revision
claus
parents:
diff changeset
    76
!CacheDictionary methodsFor:'private'!
1cf8d1747859 Initial revision
claus
parents:
diff changeset
    77
1cf8d1747859 Initial revision
claus
parents:
diff changeset
    78
findKeyOrNil:key  
1cf8d1747859 Initial revision
claus
parents:
diff changeset
    79
    "Look for the key in the receiver.  If it is found, return
1cf8d1747859 Initial revision
claus
parents:
diff changeset
    80
     the index of the association containing the key, otherwise
1cf8d1747859 Initial revision
claus
parents:
diff changeset
    81
     return the index of the first unused slot. If no empty slot
489
27859443b951 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 459
diff changeset
    82
     is available, make one empty (but never grow)."
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
    83
1cf8d1747859 Initial revision
claus
parents:
diff changeset
    84
    |index  "{ Class:SmallInteger }"
1cf8d1747859 Initial revision
claus
parents:
diff changeset
    85
     length "{ Class:SmallInteger }"
3792
ac218195f34c #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 3473
diff changeset
    86
     startIndex probe
ac218195f34c #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 3473
diff changeset
    87
     delIndex "{ Class:SmallInteger }"|
ac218195f34c #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 3473
diff changeset
    88
ac218195f34c #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 3473
diff changeset
    89
    delIndex := 0.
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
    90
1cf8d1747859 Initial revision
claus
parents:
diff changeset
    91
    length := keyArray basicSize.
1126
0ca4b7558465 refactored to invoke #hash/#identityHash only from one place
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
    92
    startIndex := index := self initialIndexForKey:key.
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
    93
3209
bed5afb12dcf [true] whileTrue: -> #loop
Stefan Vogel <sv@exept.de>
parents: 2700
diff changeset
    94
    [
238
5cd00f81c000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 134
diff changeset
    95
        probe := keyArray basicAt:index.
1126
0ca4b7558465 refactored to invoke #hash/#identityHash only from one place
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
    96
        key = probe ifTrue:[^ index].
489
27859443b951 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 459
diff changeset
    97
        probe isNil ifTrue:[
3792
ac218195f34c #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 3473
diff changeset
    98
            delIndex == 0 ifTrue:[^ index].
1126
0ca4b7558465 refactored to invoke #hash/#identityHash only from one place
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
    99
0ca4b7558465 refactored to invoke #hash/#identityHash only from one place
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   100
            keyArray basicAt:delIndex put:nil.
0ca4b7558465 refactored to invoke #hash/#identityHash only from one place
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   101
            valueArray basicAt:delIndex put:nil.
0ca4b7558465 refactored to invoke #hash/#identityHash only from one place
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   102
            ^ delIndex
489
27859443b951 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 459
diff changeset
   103
        ].
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   104
3792
ac218195f34c #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 3473
diff changeset
   105
        (delIndex == 0 and:[probe == DeletedEntry]) ifTrue:[
1126
0ca4b7558465 refactored to invoke #hash/#identityHash only from one place
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   106
            delIndex := index
238
5cd00f81c000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 134
diff changeset
   107
        ].
13
f089ff744cd1 *** empty log message ***
claus
parents: 2
diff changeset
   108
238
5cd00f81c000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 134
diff changeset
   109
        index := index + 1.
5cd00f81c000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 134
diff changeset
   110
        index > length ifTrue:[
5cd00f81c000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 134
diff changeset
   111
            index := 1.
5cd00f81c000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 134
diff changeset
   112
        ].
5cd00f81c000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 134
diff changeset
   113
        index == startIndex ifTrue:[
4673
9a0b7710fe9d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4141
diff changeset
   114
            "/ cache is full;
9a0b7710fe9d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4141
diff changeset
   115
            "/ replace the slot at the original startIndex (the H(key))
9a0b7710fe9d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4141
diff changeset
   116
            "/ 
9a0b7710fe9d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4141
diff changeset
   117
            "/ mhmh - a kind of round-robin might be better - this will always
9a0b7710fe9d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4141
diff changeset
   118
            "/ remove the first key with this H(key)
3792
ac218195f34c #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 3473
diff changeset
   119
            delIndex == 0 ifTrue:[
4673
9a0b7710fe9d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4141
diff changeset
   120
                delIndex := startIndex.
9a0b7710fe9d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4141
diff changeset
   121
                tally := tally - 1.
238
5cd00f81c000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 134
diff changeset
   122
            ].
13
f089ff744cd1 *** empty log message ***
claus
parents: 2
diff changeset
   123
1126
0ca4b7558465 refactored to invoke #hash/#identityHash only from one place
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   124
            keyArray basicAt:delIndex put:nil.
0ca4b7558465 refactored to invoke #hash/#identityHash only from one place
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   125
            valueArray basicAt:delIndex put:nil.
0ca4b7558465 refactored to invoke #hash/#identityHash only from one place
Claus Gittinger <cg@exept.de>
parents: 910
diff changeset
   126
            ^ delIndex
238
5cd00f81c000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 134
diff changeset
   127
        ].
3209
bed5afb12dcf [true] whileTrue: -> #loop
Stefan Vogel <sv@exept.de>
parents: 2700
diff changeset
   128
    ] loop.
238
5cd00f81c000 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 134
diff changeset
   129
2700
b480eda50a6a comment/format in: #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 1126
diff changeset
   130
    "Modified: / 01-03-1997 / 00:59:55 / cg"
b480eda50a6a comment/format in: #findKeyOrNil:
Claus Gittinger <cg@exept.de>
parents: 1126
diff changeset
   131
    "Modified (format): / 26-12-2011 / 10:42:08 / cg"
4843
49f5a601dee9 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4674
diff changeset
   132
    "Modified: / 15-03-2019 / 15:27:16 / Stefan Vogel"
489
27859443b951 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 459
diff changeset
   133
!
27859443b951 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 459
diff changeset
   134
4024
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   135
findKeyOrNilOrDeletedEntry:key  
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   136
    "Look for the key in the receiver.  If it is found, return
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   137
     the index of the association containing the key, otherwise
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   138
     return the index of the first unused slot. If no empty slot
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   139
     is available, make one empty (but never grow)."
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   140
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   141
    |index  "{ Class:SmallInteger }"
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   142
     length "{ Class:SmallInteger }"
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   143
     startIndex probe
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   144
     delIndex "{ Class:SmallInteger }"|
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   145
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   146
    delIndex := 0.
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   147
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   148
    length := keyArray basicSize.
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   149
    startIndex := index := self initialIndexForKey:key.
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   150
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   151
    [
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   152
        probe := keyArray basicAt:index.
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   153
        key = probe ifTrue:[^ index].
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   154
        probe isNil ifTrue:[
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   155
            delIndex == 0 ifTrue:[^ index].
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   156
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   157
            valueArray basicAt:delIndex put:nil.
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   158
            ^ delIndex
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   159
        ].
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   160
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   161
        (delIndex == 0 and:[probe == DeletedEntry]) ifTrue:[
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   162
            delIndex := index
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   163
        ].
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   164
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   165
        index := index + 1.
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   166
        index > length ifTrue:[
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   167
            index := 1.
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   168
        ].
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   169
        index == startIndex ifTrue:[
4843
49f5a601dee9 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4674
diff changeset
   170
            "/ cache is full;
49f5a601dee9 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4674
diff changeset
   171
            "/ replace the slot at the original startIndex (the H(key))
49f5a601dee9 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4674
diff changeset
   172
            "/ 
49f5a601dee9 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4674
diff changeset
   173
            "/ mhmh - a kind of round-robin might be better - this will always
49f5a601dee9 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4674
diff changeset
   174
            "/ remove the first key with this H(key)
4024
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   175
            delIndex == 0 ifTrue:[
4673
9a0b7710fe9d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4141
diff changeset
   176
                delIndex := startIndex.
9a0b7710fe9d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4141
diff changeset
   177
                tally := tally - 1.
4024
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   178
            ].
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   179
4843
49f5a601dee9 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4674
diff changeset
   180
            keyArray basicAt:delIndex put:DeletedEntry.
4024
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   181
            valueArray basicAt:delIndex put:nil.
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   182
            ^ delIndex
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   183
        ].
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   184
    ] loop.
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   185
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   186
    "Modified: / 01-03-1997 / 00:59:55 / cg"
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   187
    "Modified (format): / 26-12-2011 / 10:42:08 / cg"
4843
49f5a601dee9 #BUGFIX by stefan
Stefan Vogel <sv@exept.de>
parents: 4674
diff changeset
   188
    "Modified (format): / 15-03-2019 / 15:05:44 / Stefan Vogel"
4024
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   189
!
626a498ce5bf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3792
diff changeset
   190
3461
f4ff6526ac02 renamed the private emptyCheck of Set & Dictionary
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
   191
possiblyGrow
489
27859443b951 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 459
diff changeset
   192
    "redefined - never grow"
27859443b951 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 459
diff changeset
   193
27859443b951 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 459
diff changeset
   194
    ^ self
27859443b951 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 459
diff changeset
   195
27859443b951 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 459
diff changeset
   196
    "Modified: 30.1.1997 / 15:17:18 / cg"
3461
f4ff6526ac02 renamed the private emptyCheck of Set & Dictionary
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
   197
!
f4ff6526ac02 renamed the private emptyCheck of Set & Dictionary
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
   198
f4ff6526ac02 renamed the private emptyCheck of Set & Dictionary
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
   199
possiblyShrink
f4ff6526ac02 renamed the private emptyCheck of Set & Dictionary
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
   200
    "redefined - never shrink"
f4ff6526ac02 renamed the private emptyCheck of Set & Dictionary
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
   201
f4ff6526ac02 renamed the private emptyCheck of Set & Dictionary
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
   202
    ^ self
f4ff6526ac02 renamed the private emptyCheck of Set & Dictionary
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
   203
f4ff6526ac02 renamed the private emptyCheck of Set & Dictionary
Claus Gittinger <cg@exept.de>
parents: 3209
diff changeset
   204
    "Modified: 30.1.1997 / 15:17:12 / cg"
4674
519d0604d2bc #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   205
!
519d0604d2bc #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   206
519d0604d2bc #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   207
possiblyShrinkToZero
519d0604d2bc #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   208
    "here, we keep the old containers"
519d0604d2bc #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   209
    
519d0604d2bc #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   210
    keyArray atAllPut:nil.
519d0604d2bc #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   211
    valueArray atAllPut:nil.
519d0604d2bc #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   212
    tally := 0.
0
1cf8d1747859 Initial revision
claus
parents:
diff changeset
   213
! !
125
8ee6268bd5ed checkin from browser
Claus Gittinger <cg@exept.de>
parents: 112
diff changeset
   214
134
4ef060494a86 version at the end
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   215
!CacheDictionary class methodsFor:'documentation'!
4ef060494a86 version at the end
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   216
4ef060494a86 version at the end
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   217
version
3792
ac218195f34c #TUNING by stefan
Stefan Vogel <sv@exept.de>
parents: 3473
diff changeset
   218
    ^ '$Header$'
4674
519d0604d2bc #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   219
!
519d0604d2bc #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   220
519d0604d2bc #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   221
version_CVS
519d0604d2bc #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4673
diff changeset
   222
    ^ '$Header$'
134
4ef060494a86 version at the end
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   223
! !
3209
bed5afb12dcf [true] whileTrue: -> #loop
Stefan Vogel <sv@exept.de>
parents: 2700
diff changeset
   224