eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'SegmentedOrderedCollection':

Home

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

Class: SegmentedOrderedCollection


Inheritance:

   Object
   |
   +--Collection
      |
      +--SequenceableCollection
         |
         +--SegmentedOrderedCollection

Package:
stx:libbasic2
Category:
Collections-Sequenceable
Version:
rev: 1.17 date: 2017/01/26 10:59:02
user: cg
file: SegmentedOrderedCollection.st directory: libbasic2
module: stx stc-classLibrary: libbasic2
Author:
Claus Gittinger

Description:


SegmentedOrderedCollections are intended as a replacement for huge OrderedCollections or Lists.
They keep their elements in chunks (segments), allowing for fast 
adding/removing at either end AND relatively fast add/remove inside the collection.
Compared to regular orderedColletions, there is not much of a difference if
elements are added at either end.
However, when adding/removing inner elements, the performance of SegmentedOrderedCollections
is much better above a certain number of elements (actually quite big).

However, notice again: 
    when only removing at either end only, an OrderedCollection is faster.

The break-even in performance depends on the number of elements and the usage pattern.
Consider it with (say) > 10000 elements and many adds/removes from the inside.

This class was added to support huge selection-in-lists (>100k elements), which are
constantly changing by adding/removing elements at arbitrary positions.

Possibly unfinished (may need optimized search and replace).


Related information:

    Array
    OrderedCollection
    BTree

Class protocol:

instance creation
o  new
return an initialized instance

o  new: size
return an initialized instance with space for size elements.
However, be aware that the logical size is 0


Instance protocol:

accessing
o  at: index
return the element at index, anInteger

o  at: index put: newElement
set the element at index, to be anInteger.
Return anObject (sigh).

o  first
return the first element

o  last
return the last element

adding & removing
o  add: anObject
add anObject to the end.
Returns the object (sigh)

o  add: anObject beforeIndex: index
insert the first argument, anObject into the collection before slot index.
Return the receiver (sigh - ST-80 compatibility).

Notice that this modifies the receiver, NOT a copy.

o  addFirst: anObject
add anObject to the beginning (insert as new first element).

o  removeAll
remove all elements from the receiver. Returns the receiver.

o  removeFirst
remove the first element from the collection; return the element.
If there is no element in the receiver collection, raise an error.

o  removeFirstIfAbsent: exceptionBlock
remove the first element from the collection; return the element.
If there is no element in the receiver collection, return the value from
exceptionBlock.
Destructive: modifies the receiver

o  removeFromIndex: startIndex toIndex: endIndex
remove the elements stored under startIndex up to and including
the elements under stopIndex.
Return the receiver.
Returning the receiver here is a historic leftover - it may change.
Please use yourself in a cascade, if you need the receiver's value
when using this method.

o  removeLast
remove the last element from the collection; return the element

enumerating
o  do: aBlock
evaluate the argument, aBlock for every element in the collection.

o  keysAndValuesDo: aBlock
evaluate the argument, aBlock for every element in the collection,
passing both index and element as arguments.

grow & shrink
o  grow: newSize
adjust the logical size to newSize

initialization
o  initialize
Invoked when a new instance is created.

private
o  splitSegmentAt: segmentIndex

queries
o  isFixedSize
return true if the receiver cannot grow

o  size
return the number of elements in the collection



ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Tue, 16 Apr 2024 15:40:01 GMT