[squeak-dev] The Trunk: Collections-nice.131.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[squeak-dev] The Trunk: Collections-nice.131.mcz

commits-2
Nicolas Cellier uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-nice.131.mcz

==================== Summary ====================

Name: Collections-nice.131
Author: nice
Time: 15 September 2009, 1:13:12 am
UUID: 44251830-867d-4c53-b367-831f7960de96
Ancestors: Collections-nice.130

grab some WideCharacterSet patches from http://bugs.squeak.org/view.php?id=3574

1) A convenient #newFrom: instance creation method was missing, add it.
2) #hash was bugged, correct it and handle CharacterSet equality => hash equality
3) a period was missing in #remove:

=============== Diff against Collections-nice.130 ===============

Item was added:
+ ----- Method: WideCharacterSet class>>newFrom: (in category 'instance creation') -----
+ newFrom: aCollection
+ | newCollection |
+ newCollection := self new.
+ newCollection addAll: aCollection.
+ ^newCollection!

Item was changed:
  ----- Method: WideCharacterSet>>remove: (in category 'collection ops') -----
  remove: aCharacter
  | val high low lowmap |
  val := aCharacter asciiValue.
  high := val bitShift: -16.
  low := val bitAnd: 16rFFFF.
+ lowmap := map
- lowmap := (map
  at: high
+ ifAbsent: [^ aCharacter].
+ self clearBitmap: lowmap at: low.
- ifAbsent: [^ aCharacter]) self clearBitmap: lowmap at: low.
  lowmap max = 0
  ifTrue: [map removeKey: high].
  ^ aCharacter!

Item was changed:
  ----- Method: WideCharacterSet>>hash (in category 'comparing') -----
  hash
+ "Answer a hash code aimed at storing and retrieving the receiver in a Set or Dictionary.
+ Two equal objects should have equal hash.
+ Note: as the receiver can be equal to an ordinary CharacterSet,
+ the hash code must reflect this"
+
+ ^self hasWideCharacters
+ ifTrue: [map hash]
+ ifFalse: [self asCharacterSet hash]!
- ^self map hash!