--- a/Bag.st Mon Mar 25 23:04:02 2013 +0000
+++ b/Bag.st Wed Mar 27 12:24:15 2013 +0000
@@ -65,18 +65,32 @@
!Bag class methodsFor:'instance creation'!
+contentsClass
+ "the default class to use for the underlying contents array,
+ used when instantiated with new/new:"
+
+ ^ Dictionary
+!
+
+equalityNew
+ "return a new empty Bag.
+ Elements will be compared using equality compare (i.e. #= not #== identity)."
+
+ ^ self basicNew initContentsForEquality
+!
+
equalityNew:size
"return a new empty Bag with initial space for size elements.
Elements will be compared using equality compare (i.e. #= not #== identity)."
- ^ self basicNew initContents:size
+ ^ self basicNew initContentsForEquality:size
!
identityNew
- "return a new empty Bag which compares for identity
+ "return a new empty Identity-Bag.
Elements will be compared using identity compare (i.e. #== not #= equality)."
- ^ super new initContentsForIdentity
+ ^ self basicNew initContentsForIdentity
!
identityNew:size
@@ -364,12 +378,26 @@
!Bag methodsFor:'private'!
initContents
+ "set the contents to be an empty Dictionary.
+ This is the default method for initialization, which can be redefined in subclasses."
+
+ contents := self class contentsClass new
+!
+
+initContents:size
+ "set the contents to be an empty Dictionary with initial size.
+ This is the default method for initialization, which can be redefined in subclasses."
+
+ contents := self class contentsClass new: size
+!
+
+initContentsForEquality
"set the contents to be an empty Dictionary"
contents := Dictionary new
!
-initContents:size
+initContentsForEquality:size
"set the contents to be an empty Dictionary with initial size"
contents := Dictionary new:size
@@ -416,10 +444,10 @@
!Bag class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Bag.st,v 1.43 2013-03-19 09:22:44 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Bag.st,v 1.44 2013-03-25 21:27:48 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/Bag.st,v 1.43 2013-03-19 09:22:44 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Bag.st,v 1.44 2013-03-25 21:27:48 cg Exp $'
! !