eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'BoundedCollection':

Home

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

Class: BoundedCollection


Inheritance:

   Object
   |
   +--Collection
      |
      +--BoundedCollection

Package:
stx:libbasic2
Category:
Collections-Sequenceable
Version:
rev: 1.1 date: 2023/11/22 15:10:10
user: cg
file: BoundedCollection.st directory: libbasic2
module: stx stc-classLibrary: libbasic2
Author:
Claus Gittinger

Description:


an Collection with a maximum size.
Will raise an error when that limit is reached


Class protocol:

instance creation
o  for: aCollection maximumSize: n


Instance protocol:

accessing
o  collection: collectionArg maximumSize: maxSizeArg

o  maximumSize: maxSizeArg

message forwarding
o  add: anElement
(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  addFirst: anElement
(comment from inherited method)
add the argument, anObject to the receiver.
If the receiver is ordered, the new element will be added at the beginning.
An error is raised here - it is to be implemented by a concrete subclass.

o  checkSize

o  doesNotUnderstand: aMessage
(comment from inherited method)
this message is sent by the runtime system (VM) when
a message is not understood by some object (i.e. there
is no method for that selector). The original message has
been packed into aMessage (i.e. the receiver, selector and
any arguments) and the original receiver is then sent the
#doesNotUnderstand: message.
Here, we raise another signal which usually enters the debugger.
You can of course redefine #doesNotUnderstand: in your classes
to implement message delegation,
or handle the MessageNotUnderstood exception gracefully.

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

queries
o  size
(comment from inherited method)
return the number of elements in the receiver.
This is usually redefined in subclasses for more performance.

o  species
(comment from inherited method)
return a class which is similar to (or the same as) the receiver's class.
This is used to create an appropriate object when creating derived
copies in the collection classes (sometimes redefined).

o  speciesForAdding
(comment from inherited method)
like species, but redefined for collections which cannot grow easily.
Used by functions which create a growing collection (see collect:with:, for example)

o  speciesForCollecting
(comment from inherited method)
like species, but used when doing collect operations.
Redefined for collections which return a different classes object when doing collect.

o  speciesForCompare
(comment from inherited method)
return a class to determine if two objects can be compared.
The fallback here is my species; only redefined by some timestamp classes.
FIXME: not all classes (actually currently only one) use this in their #= method
(i.e. it needs to be done eg in Dictionary as well)

o  speciesForCopy
(comment from inherited method)
return a class which is the receiver's class, except for readonly objects,
such as immutable collections.
This is only to be used by copy methods


Examples:


|oc|

oc := BoundedCollection for:(OrderedCollection new) maximumSize:5.
oc add:1.
oc add:2.
oc add:3.
oc add:4.
oc add:5.
oc add:6. 'raises an exception'


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