eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'MappedCollection':

Home

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

Class: MappedCollection


Inheritance:

   Object
   |
   +--Collection
      |
      +--MappedCollection

Package:
stx:libbasic2
Category:
Collections-Sequenceable
Version:
rev: 1.27 date: 2021/07/09 17:13:58
user: cg
file: MappedCollection.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


MappedCollections represent collections of objects that are indirectly indexed by names.
There are really two collections involved: domain and a map.  
The map maps between external names and indices into domain, 
which contains the real association.  
In order to work properly, the domain and map objects must
be instances of a subclass of SequenceableCollection or Dictionary.
The valueDomain of the map must be the keyDomain of the domain collection.
i.e. 
    mappedCollection at:k   ==>  domain at:(map at:k)

copyright

COPYRIGHT (c) 1993 by Claus Gittinger All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

instance creation
o  collection: domainCollection map: mapCollection
return a new MappedCollection

o  new
report an error; mappedCollections may not be created using new


Instance protocol:

accessing
o  at: key
retrieve an element

o  at: key put: anObject
store an element

o  contents
return the contents as a bag

adding & removing
o  add: anObject
report an error; mappedCollections cannot add elements (without a key)

copying-private
o  postCopy
(comment from inherited method)
this is for compatibility with ST-80 code, which uses postCopy for
cleanup after copying, while ST/X passes the original in postCopyFrom:
(see there)

enumerating
o  do: aBlock
evaluate the argument, aBlock for each element

private
o  setCollection: domainCollection map: mapCollection

queries
o  isFixedSize
return true if the receiver cannot grow

o  size
return the number of elements in the receiver

o  species
return the type of collection to be returned by collect, select etc.

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


Examples:


    |mapped keyMapping|

    keyMapping := Dictionary new
                at:'uno' put:1;
                at:'due' put:2;
                at:'tre' put:3;
                at:'quattro' put:4;
                yourself.

    mapped := MappedCollection
                    collection:#(one two three four)
                    map:keyMapping.

    mapped at:'tre'.
    mapped select:[:each| each ~= 'two']


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 27 Jul 2024 08:59:17 GMT