IdentitySet.st
changeset 23839 fadefe4a762e
parent 23695 59ae587a1107
equal deleted inserted replaced
23838:598b8a8934d0 23839:fadefe4a762e
    46     [author:]
    46     [author:]
    47         Claus Gittinger
    47         Claus Gittinger
    48 "
    48 "
    49 ! !
    49 ! !
    50 
    50 
    51 !IdentitySet methodsFor:'Compatibility-Squeak'!
       
    52 
       
    53 copyWithout:anElement
       
    54     "return a new collection consisting of a copy of the receiver, with
       
    55      ALL elements equal to elementToSkip are left out.
       
    56      No error is reported, if elementToSkip is not in the collection."
       
    57 
       
    58     ^ self select:[:each | each ~~ anElement]
       
    59 
       
    60     "
       
    61      #(1 2 3 4 5 6 7) asSet copyWithout:5
       
    62     "
       
    63 ! !
       
    64 
       
    65 !IdentitySet methodsFor:'adding & removing'!
    51 !IdentitySet methodsFor:'adding & removing'!
    66 
    52 
    67 removeIdentical:oldObject ifAbsent:exceptionBlock
    53 removeIdentical:oldObject ifAbsent:exceptionBlock
    68     "remove oldObject from the collection and return it.
    54     "remove oldObject from the collection and return it.
    69      If it was not in the collection return the value of exceptionBlock.
    55      If it was not in the collection return the value of exceptionBlock.
    98     "
    84     "
    99         |s|
    85         |s|
   100         s := #(1 2 3 4) asIdentitySet.
    86         s := #(1 2 3 4) asIdentitySet.
   101         self assert:(s ~~ s asNewIdentitySet).
    87         self assert:(s ~~ s asNewIdentitySet).
   102         self assert:(s = s asNewIdentitySet).
    88         self assert:(s = s asNewIdentitySet).
       
    89     "
       
    90 ! !
       
    91 
       
    92 !IdentitySet methodsFor:'copying'!
       
    93 
       
    94 copyWithout:anElement
       
    95     "return a new collection consisting of a copy of the receiver, with
       
    96      ALL elements equal to elementToSkip are left out.
       
    97      No error is reported, if elementToSkip is not in the collection."
       
    98 
       
    99     ^ self select:[:each | each ~~ anElement]
       
   100 
       
   101     "
       
   102      #(1 2 3 4 5 6 7) asSet copyWithout:5
   103     "
   103     "
   104 ! !
   104 ! !
   105 
   105 
   106 !IdentitySet methodsFor:'private'!
   106 !IdentitySet methodsFor:'private'!
   107 
   107