eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'SkipList':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: SkipList


Inheritance:

   Object
   |
   +--Collection
      |
      +--SkipList
         |
         +--IdentitySkipList

Package:
stx:libbasic2
Category:
Collections-Ordered-Trees
Version:
rev: 1.1 date: 2017/06/18 15:49:18
user: cg
file: SkipList.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


From 'Skip Lists: A Probabilistic Alternative to Balanced Trees' by William Pugh 
( http://epaperpress.com/sortsearch/download/skiplist.pdf ):

Skip lists are a data structure that can be used in place of balanced trees.  
Skip lists use probabilistic balancing rather than strictly enforcing balancing 
and as a result the algorithms for insertion and deletion in skip lists are much simpler 
and significantly faster than equivalent algorithms for balanced trees.

Notes:

The elements of the skip list must implement #< or you must provide a sort block.


Class protocol:

instance creation
o  maxLevel: maxLevel
SkipList maxLevel: 5

o  maxLevel: anInteger sortBlock: aBlock

o  new
SkipList new

o  new: anInteger
(comment from inherited method)
return an instance of myself with anInteger indexed variables

o  new: anInteger sortBlock: aBlock

o  sortBlock: aBlock


Instance protocol:

accessing
o  level

o  maxLevel

o  maxLevel: n
Modified (format): / 18-06-2017 / 17:42:51 / cg

o  size

o  sortBlock

o  sortBlock: aBlock
Modified (format): / 18-06-2017 / 17:44:44 / cg

adding
o  add: element
(comment from inherited method)
add the argument, anObject to the receiver.
If the receiver is ordered, the position of the new element is undefined
(i.e. don't depend on where it will be put).
An error is raised here - it is to be implemented by a concrete subclass.

o  add: element ifPresent: aBlock

element comparison
o  is: element1 equalTo: element2

enumerating
o  do: aBlock
(comment from inherited method)
evaluate the argument, aBlock for each element.
Return the receiver
(subclasses should care to also return the receiver,
in case do: is used in a chain of messages.)

initialization
o  initialize: maxLevel

node enumeration
o  nodesDo: aBlock
Modified (format): / 18-06-2017 / 17:31:41 / cg

private
o  atForward: i put: node
Modified (format): / 18-06-2017 / 17:32:30 / cg

o  forward: i

o  is: node before: element

o  is: node theNodeFor: element

o  next

o  randomLevel
Modified (format): / 18-06-2017 / 17:42:59 / cg

o  search: element updating: array
At this point: node < element <= forward

removing
o  remove: element ifAbsent: aBlock
Modified (format): / 18-06-2017 / 17:43:30 / cg

o  removeAll
Modified (format): / 18-06-2017 / 17:43:39 / cg

testing
o  includes: element
(comment from inherited method)
return true, if an element equal to the argument, searchedElement is in the collection.
This compares using #= (i.e. it does not look for the object itself,
instead, one that compares equal).
See #includesIdentical: when identity is asked for.
This is a *very* slow fallback - many subclasses redefine this for performance.

o  isEmpty
(comment from inherited method)
return true, if the receiver is empty



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 21 Dec 2024 16:36:11 GMT