Colecciones Smalltalk

Páginas: 4 (826 palabras) Publicado: 17 de abril de 2012
Chapter

11
Collections
Collections are objects that contain a group of other objects. Collections are among the most useful classes in Smalltalk and you'll find yourself using them constantly —even a string is nothing more than a collection of characters. The top level collection class is Collection, which is an abstract superclass that provides the generic behavior common to allcollections. For example, Collection implements the methods size and capacity, the testing methods isEmpty, contains:, and includes:, the converting methods such as asArray, asOrderedCollection, the powerfulenumeration methods such as do: and collect:, and the basic adding and removing methods add:, remove:, and remove:ifAbsent:. (Many of these methods are inherited by subclasses of Collection, butsome act as placeholders to tell subclasses they should implement the method appropriately.) The main subclasses of Collection that you will use are Bag, Set, and SequenceableCollection.SequenceableCollection is an abstract superclass for all the collections that understand sequencing, such as Array, OrderedCollection, and String. Because it expects all its subclasses to understand the concept ofsequencing, SequenceableCollection adds behavior such as first and last, which is not generic enough to be placed in Collection. As we go further down the hierarchy, each subclass providesincreasingly specific functionality, sometimes by adding new methods and sometimes by overriding methods defined in one of its superclasses. The hierarchy of basic collection classes that you will use is shownin Figure 11-1.

Copyright © 1997 by Alec Sharp Download more free Smalltalk-Books at: - The University of Berne: http://www.iam.unibe.ch/~ducasse/WebPages/FreeBooks.html - European SmalltalkUsers Group: http://www.esug.org

Collections

2

Collection

SequenceableCollection

Bag

Set

ArrayedCollection

Interval

OrderedCollection

LinkedList

Dictionary

Array...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Apunte Colecciones Smalltalk
  • Smalltalk
  • smalltalk
  • coleccion
  • Coleccion
  • el coleccionista
  • Coleccion
  • el coleccionista

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS