added keysDo: and includesKey: for protocol completeness.
--- a/NameSpace.st Fri Jul 16 18:46:35 1999 +0200
+++ b/NameSpace.st Fri Jul 16 19:24:42 1999 +0200
@@ -265,6 +265,20 @@
^ Smalltalk classNamed:(self name , '::' , aString)
"Created: 9.9.1997 / 03:33:56 / cg"
+!
+
+includesKey:aClassNameStringOrSymbol
+ "{ Pragma: +optSpace }"
+
+ "return true if such a key is present"
+
+ |nmSym|
+
+ nmSym := (self name , '::' , aClassNameStringOrSymbol) asSymbolIfInterned.
+ nmSym isNil ifTrue:[^ false].
+ ^ Smalltalk includesKey:nmSym.
+
+
! !
!Namespace class methodsFor:'enumerating'!
@@ -281,6 +295,28 @@
].
"Modified: / 18.3.1999 / 17:21:06 / cg"
+!
+
+keysDo:aBlock
+ "enumerate all class names in this namespace"
+
+ |prefix prefixLen|
+
+ prefix := self name , '::'.
+ prefixLen := prefix size.
+
+ Smalltalk keysAndValuesDo:[:aName :aClass |
+ |key|
+
+ (aName startsWith:prefix) ifTrue:[
+ key := (aName copyFrom:prefixLen+1) asSymbol.
+ aBlock value:key
+ ]
+ ].
+
+ "
+ Benchmarks keysDo:[:k | Transcript showCR:k]
+ "
! !
!Namespace class methodsFor:'fileOut'!
@@ -298,6 +334,19 @@
"Created: 4.1.1997 / 20:36:32 / cg"
! !
+!Namespace class methodsFor:'inspecting'!
+
+inspectorClass
+ "{ Pragma: +optSpace }"
+
+ "redefined to launch a DictionaryInspector
+ (instead of the default Inspector)."
+
+ ^ DictionaryInspectorView
+
+
+! !
+
!Namespace class methodsFor:'printing & storing'!
displayString
@@ -346,5 +395,5 @@
!Namespace class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/NameSpace.st,v 1.29 1999-07-12 07:46:52 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/NameSpace.st,v 1.30 1999-07-16 17:24:42 cg Exp $'
! !
--- a/Namespace.st Fri Jul 16 18:46:35 1999 +0200
+++ b/Namespace.st Fri Jul 16 19:24:42 1999 +0200
@@ -265,6 +265,20 @@
^ Smalltalk classNamed:(self name , '::' , aString)
"Created: 9.9.1997 / 03:33:56 / cg"
+!
+
+includesKey:aClassNameStringOrSymbol
+ "{ Pragma: +optSpace }"
+
+ "return true if such a key is present"
+
+ |nmSym|
+
+ nmSym := (self name , '::' , aClassNameStringOrSymbol) asSymbolIfInterned.
+ nmSym isNil ifTrue:[^ false].
+ ^ Smalltalk includesKey:nmSym.
+
+
! !
!Namespace class methodsFor:'enumerating'!
@@ -281,6 +295,28 @@
].
"Modified: / 18.3.1999 / 17:21:06 / cg"
+!
+
+keysDo:aBlock
+ "enumerate all class names in this namespace"
+
+ |prefix prefixLen|
+
+ prefix := self name , '::'.
+ prefixLen := prefix size.
+
+ Smalltalk keysAndValuesDo:[:aName :aClass |
+ |key|
+
+ (aName startsWith:prefix) ifTrue:[
+ key := (aName copyFrom:prefixLen+1) asSymbol.
+ aBlock value:key
+ ]
+ ].
+
+ "
+ Benchmarks keysDo:[:k | Transcript showCR:k]
+ "
! !
!Namespace class methodsFor:'fileOut'!
@@ -298,6 +334,19 @@
"Created: 4.1.1997 / 20:36:32 / cg"
! !
+!Namespace class methodsFor:'inspecting'!
+
+inspectorClass
+ "{ Pragma: +optSpace }"
+
+ "redefined to launch a DictionaryInspector
+ (instead of the default Inspector)."
+
+ ^ DictionaryInspectorView
+
+
+! !
+
!Namespace class methodsFor:'printing & storing'!
displayString
@@ -346,5 +395,5 @@
!Namespace class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Attic/Namespace.st,v 1.29 1999-07-12 07:46:52 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Attic/Namespace.st,v 1.30 1999-07-16 17:24:42 cg Exp $'
! !