eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'SequenceWithSentinel':

Home

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

Class: SequenceWithSentinel


Inheritance:

   Object
   |
   +--Collection
      |
      +--SequenceableCollection
         |
         +--SequenceWithSentinel

Package:
stx:libbasic2
Category:
Collections-Sequenceable
Version:
rev: 1.4 date: 2021/01/20 14:07:02
user: cg
file: SequenceWithSentinel.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


A collection with a default value for out-of-bounds accessed values.

copyright

Jun430 (2002/05/28) Copyleft 1996-2002 AOKI Atsushi, ODA Tomohiro, HOSHI Takanori, NISHINAKA Yoshiyuki, YAMADA Ryousuke, WATANABE Katsuhiro, Ankur J. Chavda, NISHIHARA Satoshi, MATSUDA Ryouichi, MATSUO Minoru, Brent N. Reeves, ASAOKA Hiroko, and TANAKA Shinichi.

Class protocol:

instance creation
o  new
(comment from inherited method)
return an instance of myself without indexed variables

o  on: aSequence sentinel: anObject
return a new collection based on aSequence but with invalid bounds-accesses returning abObject


Instance protocol:

accessing
o  at: anIndex
return the element at anIndex, or sentinel if the index is invalid

o  at: anIndex put: anObject
(comment from inherited method)
store the 2nd arg, anObject as indexed instvar with index, anInteger.
this method can be redefined in subclasses. Returns anObject (sigh)

o  size
answer my size

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

growing
o  grow: howBig
(comment from inherited method)
change the receiver's size

private
o  sentinel: anObject
set the sentinel - the value returned for invalid indices

o  sequence: aSequence
set the underlying collection

o  sequence: aSequence sentinel: aSentinelValue
set the underlying collection and the sentinel (default)

testing
o  isFixedSize
return true if the receiver cannot grow


Examples:


    |coll|

    coll := SequenceWithSentinel on:#(10 20 30 40 50) sentinel:'invalid'.
    Transcript show:'1->'; showCR:(coll at:1).
    Transcript show:'5->'; showCR:(coll at:5).
    Transcript show:'6->'; showCR:(coll at:6).
    coll do:[:each | Transcript showCR:each].


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 04:31:04 GMT