|
Class: BoundedCollection
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
an Collection with a maximum size.
Will raise an error when that limit is reached
instance creation
-
for: aCollection maximumSize: n
-
accessing
-
collection: collectionArg maximumSize: maxSizeArg
-
-
maximumSize: maxSizeArg
-
message forwarding
-
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.
-
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.
-
checkSize
-
-
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.
-
grow: howBig
-
(comment from inherited method)
change the receiver's size
queries
-
size
-
(comment from inherited method)
return the number of elements in the receiver.
This is usually redefined in subclasses for more performance.
-
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).
-
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)
-
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.
-
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)
-
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
|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'
|