SharedCollection.st
author Claus Gittinger <cg@exept.de>
Mon, 22 Nov 2010 21:09:26 +0100
changeset 2515 104080163067
parent 1929 5271aca614c2
child 2927 b7b7931cb32d
permissions -rw-r--r--
more operations without dnu-overhead
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 2006 by eXept Software AG
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
              All Rights Reserved
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libbasic2' }"
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
Collection subclass:#SharedCollection
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	instanceVariableNames:'accessLock realCollection'
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	classVariableNames:''
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
2515
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
    18
	category:'Collections-Support'
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!SharedCollection class methodsFor:'documentation'!
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
copyright
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
"
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
 COPYRIGHT (c) 2006 by eXept Software AG
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
              All Rights Reserved
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
 This software is furnished under a license and may be used
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 only in accordance with the terms of that license and with the
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 be provided or otherwise made available to, or used by, any
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 other person.  No title to or ownership of the software is
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 hereby transferred.
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
"
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
!
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
documentation
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
"
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
    Instances of this class provide synchronized access (of multiple processes) 
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
    to a collection.
1636
a3e5703901c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1635
diff changeset
    41
a3e5703901c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1635
diff changeset
    42
    Notice: the message-forwarding is done by catching sbclassResponsibility and
a3e5703901c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1635
diff changeset
    43
    doesNotUnderstand errors.
a3e5703901c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1635
diff changeset
    44
    For performance, and for more complex operation-atomicy, more messages might need
a3e5703901c8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1635
diff changeset
    45
    an explicit handling. See the implementation of #at: / #at:put: and #size for examples.
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
"
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
!
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
examples
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
"
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
                                        [exBegin]
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
        |c|
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
        c := SharedCollection for:(OrderedCollection new).
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
        c add:1.
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
        c add:2.
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
        c add:3.
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
        c addAll:#(4 5 6).
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
        c removeFirst.
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
        c removeLast.
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
        c inspect.
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
                                        [exEnd]
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
                                        [exBegin]
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
        |c|
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
        c := SharedCollection for:(Array new:10).
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
        c at:1 put:5.
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
        c replaceFrom:2 to:5 with:#(20 30 40 50).
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
        c inspect.
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
                                        [exEnd]
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
"
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
! !
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
!SharedCollection class methodsFor:'instance creation'!
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
for:aCollection
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
    ^ self new initializeFor:aCollection
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
! !
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
1634
466927adcd9c +asSharedCollection
Claus Gittinger <cg@exept.de>
parents: 1632
diff changeset
    81
!SharedCollection methodsFor:'converting'!
466927adcd9c +asSharedCollection
Claus Gittinger <cg@exept.de>
parents: 1632
diff changeset
    82
466927adcd9c +asSharedCollection
Claus Gittinger <cg@exept.de>
parents: 1632
diff changeset
    83
asSharedCollection
466927adcd9c +asSharedCollection
Claus Gittinger <cg@exept.de>
parents: 1632
diff changeset
    84
    ^ self.
466927adcd9c +asSharedCollection
Claus Gittinger <cg@exept.de>
parents: 1632
diff changeset
    85
! !
466927adcd9c +asSharedCollection
Claus Gittinger <cg@exept.de>
parents: 1632
diff changeset
    86
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
!SharedCollection methodsFor:'initialization'!
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
initializeFor:aCollection
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
    accessLock := RecursionLock new.
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
    realCollection := aCollection.
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
! !
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
!SharedCollection methodsFor:'message forwarding'!
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
1929
Claus Gittinger <cg@exept.de>
parents: 1794
diff changeset
    96
add:anElement
Claus Gittinger <cg@exept.de>
parents: 1794
diff changeset
    97
    |rslt|
Claus Gittinger <cg@exept.de>
parents: 1794
diff changeset
    98
Claus Gittinger <cg@exept.de>
parents: 1794
diff changeset
    99
    accessLock critical:[
Claus Gittinger <cg@exept.de>
parents: 1794
diff changeset
   100
        rslt := realCollection add:anElement
Claus Gittinger <cg@exept.de>
parents: 1794
diff changeset
   101
    ].
Claus Gittinger <cg@exept.de>
parents: 1794
diff changeset
   102
    ^ rslt
Claus Gittinger <cg@exept.de>
parents: 1794
diff changeset
   103
!
Claus Gittinger <cg@exept.de>
parents: 1794
diff changeset
   104
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
at:index
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
    |rslt|
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
    accessLock critical:[
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
        rslt := realCollection at:index
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
    ].
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    ^ rslt
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
!
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
at:index put:value
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
    |rslt|
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
    accessLock critical:[
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
        rslt := realCollection at:index put:value
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
    ].
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
    ^ rslt
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
!
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
2515
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   123
do:aBlock
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   124
    |rslt|
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   125
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   126
    accessLock critical:[
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   127
        rslt := realCollection do:aBlock
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   128
    ].
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   129
    ^ rslt
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   130
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   131
    "Created: / 22-11-2010 / 21:01:21 / cg"
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   132
!
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   133
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
doesNotUnderstand:aMessage
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
    "catches everything not understood by the collection protocol"
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
    |msg rslt|
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
1794
603885d999ca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1637
diff changeset
   139
    "/ msg := thisContext sender message.
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
    accessLock critical:[
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
        rslt := aMessage sendTo:realCollection
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
    ].
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
    ^ rslt
1794
603885d999ca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1637
diff changeset
   144
603885d999ca *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1637
diff changeset
   145
    "Modified: / 07-12-2006 / 17:38:30 / cg"
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
!
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
2515
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   148
isEmpty
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   149
    |rslt|
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   150
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   151
    accessLock critical:[
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   152
        rslt := realCollection isEmpty
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   153
    ].
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   154
    ^ rslt
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   155
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   156
    "Created: / 22-11-2010 / 20:59:01 / cg"
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   157
!
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   158
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   159
notEmpty
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   160
    |rslt|
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   161
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   162
    accessLock critical:[
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   163
        rslt := realCollection notEmpty
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   164
    ].
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   165
    ^ rslt
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   166
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   167
    "Created: / 22-11-2010 / 20:59:06 / cg"
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   168
!
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   169
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   170
removeAllSuchThat:aBlock
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   171
    |rslt|
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   172
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   173
    accessLock critical:[
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   174
        rslt := realCollection removeAllSuchThat:aBlock
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   175
    ].
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   176
    ^ rslt
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   177
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   178
    "Created: / 22-11-2010 / 20:59:27 / cg"
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   179
!
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   180
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   181
removeIdentical:someElement ifAbsent:aBlock
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   182
    |rslt|
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   183
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   184
    accessLock critical:[
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   185
        rslt := realCollection removeIdentical:someElement ifAbsent:aBlock
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   186
    ].
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   187
    ^ rslt
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   188
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   189
    "Created: / 22-11-2010 / 21:00:33 / cg"
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   190
!
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   191
1635
a3aaefef0a2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1634
diff changeset
   192
size
a3aaefef0a2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1634
diff changeset
   193
    |rslt|
a3aaefef0a2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1634
diff changeset
   194
a3aaefef0a2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1634
diff changeset
   195
    accessLock critical:[
a3aaefef0a2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1634
diff changeset
   196
        rslt := realCollection size
a3aaefef0a2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1634
diff changeset
   197
    ].
a3aaefef0a2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1634
diff changeset
   198
    ^ rslt
a3aaefef0a2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1634
diff changeset
   199
!
a3aaefef0a2c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1634
diff changeset
   200
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
subclassResponsibility
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
    "catches every required message of the collection protocol"
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
    |msg rslt|
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
    msg := thisContext sender message.
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
    accessLock critical:[
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
        rslt := msg sendTo:realCollection
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
    ].
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
    ^ rslt
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
! !
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
1637
72a61c17925c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1636
diff changeset
   213
!SharedCollection methodsFor:'special'!
72a61c17925c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1636
diff changeset
   214
72a61c17925c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1636
diff changeset
   215
species
72a61c17925c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1636
diff changeset
   216
    "returns non shared collections"
72a61c17925c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1636
diff changeset
   217
72a61c17925c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1636
diff changeset
   218
    ^ realCollection species
72a61c17925c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1636
diff changeset
   219
! !
72a61c17925c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1636
diff changeset
   220
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
!SharedCollection class methodsFor:'documentation'!
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
version
2515
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   224
    ^ '$Header: /cvs/stx/stx/libbasic2/SharedCollection.st,v 1.8 2010-11-22 20:09:26 cg Exp $'
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   225
!
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   226
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   227
version_CVS
104080163067 more operations without dnu-overhead
Claus Gittinger <cg@exept.de>
parents: 1929
diff changeset
   228
    ^ '$Header: /cvs/stx/stx/libbasic2/SharedCollection.st,v 1.8 2010-11-22 20:09:26 cg Exp $'
1632
f0c09d48b17f initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
! !