eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'List':

Home

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

Class: List


Inheritance:

   Object
   |
   +--Collection
      |
      +--SequenceableCollection
         |
         +--OrderedCollection
            |
            +--List
               |
               +--AbstractFileBrowser::DirectoryHistory
               |
               +--HierarchicalList
               |
               +--Tools::TagList

Package:
stx:libbasic2
Category:
Collections-Sequenceable
Version:
rev: 1.53 date: 2019/06/07 11:52:30
user: cg
file: List.st directory: libbasic2
module: stx stc-classLibrary: libbasic2
Author:
Claus Gittinger

Description:


Lists are mostly like OrderedCollections, but keep their dependents
locally (which is adding a bit of performance - not functionality).
In addition, special change notifications are emitted, whenever
a list's contents is changed.
Some views (SelectionIn*View and DataSetView) react specially on
those messages and perform optimized updates.
(the change messages pass the range-of-change as parameter).

In ST/X, most functionality is already provided by OrderedCollection,
so there is not much new stuff found here.
It has been mostly provided, for ST-80 compatibility,
where it adds sorting capabilities.

New: 
    if the optional optionalAccessLock is set, all operations
    are protected by a critical region.
    (i.e. the List is a SynchronizedCollection)
    
[caveat:]
    'List' is probably a bad name, which may confuse beginners.
    I have nothing in common with LinkedLists.
    Instances are just regular ordered collections, with the added benefit of
    sending out information about changes, and an optional synchronization lock.
    Thus, they can be used as a model of textviews or selection list views,
    which need to redraw whenever the contents of the list changes.
    (and Lists not only send out change notifications when modified,
     but also include information about the range of changed elements.
     So the view can optimize its redraws)
    


Related information:

    Array
    OrderedCollection

Instance protocol:

accessing
o  at: anIndex put: anObject
set the element at index, to be anIndex.
Return anObject (sigh).
In contrast to OrderedCollection, Lists allow putting an object
right after the last element and auto-grow in this case;
however, putting 2 or more indices after the last element is
reported as an error.

o  list

o  synchronizationSemaphore
return a synchronization semaphore for myself

adding & removing
o  add: anObject
add the argument, anObject to the end of the collection
Return the argument, anObject.

o  add: anObject after: oldObject
insert the argument, newObject after oldObject.
If oldObject is not in the receiver, report an error,
otherwise return the argument, anObject.

o  add: anObject beforeIndex: index
add the argument, anObject to the end of the collection.
Return the receiver (sigh - ST-80 compatibility).

o  addAll: aCollection beforeIndex: index
insert all elements of the argument
Return the receiver.

o  addAll: aCollection from: startIndex to: endIndex beforeIndex: index
insert elements start to stop from the argument
Return the receiver.

o  addAllLast: aCollection
add all elements of the argument, aCollection to the end of the collection.
Return the argument, aCollection.

o  addFirst: anObject
add the argument, anObject to the beginning of the collection.
Return the argument, anObject.

o  clearContents
remove all elements from the collection but keep the contentsArray.
Useful for huge lists, if the contents will be rebuild soon (using #add:)
to a size which is similar to the lists current size.
Returns the receiver.

o  dropLast: n
remove the last n elements from the receiver collection.
Return the receiver.

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

o  removeAllSuchThat: aBlock
remove all elements that meet a test criteria as specified in aBlock.
The argument, aBlock is evaluated for successive elements and all those,
for which it returns true, are removed.
Destructive: modifies the receiver.
Return a collection containing the removed elements.

o  removeFirst
remove the first element from the collection; return the element.

o  removeFirst: n
remove the first n elements from the collection;
Return a collection containing the removed elements.

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.

o  removeFromIndex: startIndex toIndex: stopIndex
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.

o  removeIdentical: anObject ifAbsent: exceptionBlock
remove the first element which is identical to anObject;
if found, remove and return it;
if not, return the value from evaluating exceptionBlock.
Uses identity compare (==) to search for the element.

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

o  removeLast: n
remove the last n elements from the receiver collection.
Return a collection of removed elements.

o  removeLastIfAbsent: exceptionBlock
remove the last element from the collection; return the element.
If there is no element in the receiver collection, return the value from
exceptionBlock.

o  reset
logically remove all elements from the collection.
That's almost the same as #removeAll, but keeps the contentsArray.
Returns the receiver.

converting
o  asList
(comment from inherited method)
return a new List with the receiver collection's elements

o  asSharedCollection
I am alreay protected against concurrent access

copying
o  skipInstvarIndexInDeepCopy: index
a helper for deepCopy; only indices for which this method returns
false are copied in a deep copy.

dependents access
o  addDependent: anObject
make the argument, anObject be a dependent of the receiver.

o  dependents
return the dependents of the receiver

o  dependents: aCollection
set the dependents of the receiver

o  nonWeakDependents
return a Collection of dependents - empty if there is none.
Since all dependencies are nonWeak in List, this is a dummy.

o  nonWeakDependents: newDeps
return a Collection of dependents - empty if there is none.
Since all dependencies are nonWeak in List, this is a dummy.

o  removeDependent: anObject
make the argument, anObject be independent of the receiver.
Since all dependencies are nonWeak in Model, this is simply
forwarded to removeDependent:

filling & replacing
o  contents: aCollection
replace all elements in the receiver by aCollection,
Redefined - can be done faster

o  list: aCollection
replace all elements in the receiver by aCollection.
For compatibility with other smalltalks
(allows List to be sometimes used as a ListPresenter in ported Dolphin apps)

o  replaceFrom: start to: stop with: aCollection startingAt: repStart
replace elements in the receiver between index start and stop,
with elements taken from replacementCollection starting at repStart.
Redefined - can be done faster

o  setContents: aCollection
replace the receiver's underlying collection by aCollection

private
o  possiblySynchronized: aBlock

o  synchronized: aBlock
a shortcut, if the sync-sema is already present;
return the value from aBlock

setup
o  beSynchronized
make the receiver a synchronized List

testing
o  isList
return true, if the receiver is some kind of list collection;
true is returned here - the method is redefined from Object.



ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Tue, 19 Mar 2024 10:12:44 GMT