BTree.st
changeset 2586 aa79488454ed
parent 2487 5872274c4abd
child 2699 0848b8b6a294
equal deleted inserted replaced
2585:af78d4b32e4d 2586:aa79488454ed
   230         Dual licensed under both SqueakL and MIT. 
   230         Dual licensed under both SqueakL and MIT. 
   231         This enables both base Squeak inclusion and 100% reuse.
   231         This enables both base Squeak inclusion and 100% reuse.
   232 "
   232 "
   233 ! !
   233 ! !
   234 
   234 
       
   235 !BTree::BTreeKeys methodsFor:'accessing'!
       
   236 
       
   237 first
       
   238     ^ self at:1
       
   239 
       
   240     "Modified (format): / 02-08-2011 / 09:19:05 / cg"
       
   241 ! !
       
   242 
   235 !BTree::BTreeKeys methodsFor:'as yet unclassified'!
   243 !BTree::BTreeKeys methodsFor:'as yet unclassified'!
   236 
   244 
       
   245 emptyCopy
       
   246     ^ self class new:self size
       
   247 
       
   248     "Modified (format): / 02-08-2011 / 09:19:22 / cg"
       
   249 !
       
   250 
       
   251 findIndexForKey:aMagnitude 
       
   252     self 
       
   253         withIndexDo:[:key :i | 
       
   254             (key isNil or:[ key > aMagnitude ]) ifTrue:[
       
   255                 ^ i - 1
       
   256             ]
       
   257         ].
       
   258     ^ self size
       
   259 
       
   260     "Modified (format): / 02-08-2011 / 09:19:10 / cg"
       
   261 !
       
   262 
       
   263 shiftLeftTo:index 
       
   264     index to:self size - 1 by:1 do:[:i | 
       
   265         self at:i put:(self at:i + 1)
       
   266     ].
       
   267     self at:self size put:nil.
       
   268 
       
   269     "Modified (format): / 02-08-2011 / 09:18:52 / cg"
       
   270 !
       
   271 
       
   272 shiftRightFrom:index 
       
   273     self size to:index + 1 by:-1 do:[:i | 
       
   274         self at:i put:(self at:i - 1)
       
   275     ]
       
   276 
       
   277     "Modified (format): / 02-08-2011 / 09:18:57 / cg"
       
   278 ! !
       
   279 
       
   280 !BTree::BTreeKeys methodsFor:'enumeration'!
       
   281 
       
   282 withIndexDo:aBlock 
       
   283     1 to:self size do:[:i | 
       
   284         aBlock value:(self at:i) value:i
       
   285     ]
       
   286 
       
   287     "Modified (format): / 02-08-2011 / 09:19:01 / cg"
       
   288 ! !
       
   289 
       
   290 !BTree::BTreeKeys methodsFor:'queries'!
       
   291 
   237 canGrow
   292 canGrow
   238 	^ (self at: self size) isNil
   293     ^ (self at:self size) isNil
       
   294 
       
   295     "Modified (format): / 02-08-2011 / 09:19:27 / cg"
   239 !
   296 !
   240 
   297 
   241 canShrink
   298 canShrink
   242 	^  (self at: self size // 2 + 1) notNil
   299     ^ (self at:self size // 2 + 1) notNil
   243 !
   300 
   244 
   301     "Modified (format): / 02-08-2011 / 09:19:23 / cg"
   245 emptyCopy
       
   246 	^ self class new: self size
       
   247 !
       
   248 
       
   249 findIndexForKey: aMagnitude
       
   250 	self withIndexDo:
       
   251 		[:key :i |
       
   252 		(key isNil or: [key > aMagnitude]) ifTrue:
       
   253 			[^ i - 1]].
       
   254 	^ self size
       
   255 !
       
   256 
       
   257 first
       
   258 	^ self at: 1
       
   259 !
       
   260 
       
   261 shiftLeftTo: index
       
   262 	index to: self size - 1 by: 1 do:
       
   263 		[:i |
       
   264 		self at: i put: (self at: i+1)].
       
   265 	self at: self size put: nil.
       
   266 !
       
   267 
       
   268 shiftRightFrom: index
       
   269 	self size to: index+1 by: -1 do:
       
   270 		[:i |
       
   271 		self at: i put: (self at: i - 1)]
       
   272 	
       
   273 !
       
   274 
       
   275 withIndexDo: aBlock
       
   276 	1 to: self size do: [:i | aBlock value: (self at: i) value: i]
       
   277 ! !
   302 ! !
   278 
   303 
   279 !BTree::BTreeKeysArray class methodsFor:'documentation'!
   304 !BTree::BTreeKeysArray class methodsFor:'documentation'!
   280 
   305 
   281 documentation
   306 documentation
   364 
   389 
   365     "Modified: / 08-08-2010 / 14:39:17 / cg"
   390     "Modified: / 08-08-2010 / 14:39:17 / cg"
   366 !
   391 !
   367 
   392 
   368 keysDo: aBlock
   393 keysDo: aBlock
   369 	keys withIndexDo:
   394     keys withIndexDo:[:key :i |
   370 		[:key :i |
   395         key isNil ifTrue:[^ self].
   371 		key ifNotNil: [aBlock value: key] ifNil: [^ self]]
   396         aBlock value: key
       
   397     ]
       
   398 
       
   399     "Modified: / 02-08-2011 / 09:17:49 / cg"
   372 !
   400 !
   373 
   401 
   374 leavesFrom: start to: end do: aBlock
   402 leavesFrom: start to: end do: aBlock
   375 	self subclassResponsibility
   403 	self subclassResponsibility
   376 !
   404 !
   835 ! !
   863 ! !
   836 
   864 
   837 !BTree class methodsFor:'documentation'!
   865 !BTree class methodsFor:'documentation'!
   838 
   866 
   839 version_CVS
   867 version_CVS
   840     ^ '$Header: /cvs/stx/stx/libbasic2/BTree.st,v 1.8 2010-08-24 08:28:45 cg Exp $'
   868     ^ '$Header: /cvs/stx/stx/libbasic2/BTree.st,v 1.9 2011-08-02 07:36:21 cg Exp $'
   841 ! !
   869 ! !