ORIGIN 'container'; LIB_DEF 'arraycont' '../lib'; BODY 'private/arrayContainerBody'; (* * COPYRIGHT * Copyright (C) Mjolner Informatics, 1992-98 * All rights reserved. *) --- lib: attributes --- arrayContainer: container (* ArrayContainer is an abstraction of a repetition, offering * container capabilities as well as repetition capabilities. * Furthermore, arrayContainer implements three popular sorting * algorithms on the elements in the arrayContainer. Defines the * operations: * capacityInitial, capacityIncrement, capacityExtend, * get, put, delete, bubbleSort, shellSort, quickSort *) (# <<SLOT arrayContainerLib: attributes>>; less:< booleanValue (* should be further bound to contain an ordering operation to * be used by the sorting algorithms. Less is only used during * sorting, and can therefore be ignored if sorting is not * applied. *) (# left, right: ^element enter (left[],right[]) do INNER #); init::< (# ... #); clear::< (# ... #); empty::< (# ... #); size::< (# ... #); capacity::< (# ... #); capacityInitial:< integerObject(# do 25->value; INNER #); capacityIncrement:< integerObject(# do 10->value; INNER #); (* -1 means double *) capacityExtend:< (# ... #); find::(# ... #); copy::(# ... #); has::(# ... #); put:< (* Takes an element and an index position and inserts the * element at that position *) (# elm: ^element; inx: @integer enter (elm[],inx) ... #); get:< (* Takes an index position and returns the element at that * position *) (# elm: ^element; inx: @integer enter inx ... exit elm[] #); delete:< (* Takes an index position and deletes the element at that * position (the deleted element is returned) *) (# inx: @integer; elm: ^element; enter inx ... exit elm[] #); bubbleSort: (* Takes an index position and sorts the elements in positions * [1: n], using the bubblesort algorithm *) (# n: @integer enter n do ...; INNER exit this(arrayContainer)[] #); shellSort: (* Takes an index position and sorts the elements in positions * [1: n], using the shellsort algorithm *) (# n: @integer enter n do ...; INNER exit this(arrayContainer)[] #); quickSort: (* Takes an index position and sorts the elements in positions * [1: n], using the quicksort algorithm *) (# n: @integer; enter n do ...; INNER exit this(arrayContainer)[] #); doEnter::< (# containerType::<arrayContainer ... #); theCellType::< (* Private *) (# occupied: @boolean; copy::< (# do elm[]->theCellCopy.elm[]; occupied->theCellCopy.occupied; INNER #) enter elm[] do INNER exit elm[] #); theScanner::< (# ... #); private: (* Private *) @... do INNER #)
6.7 ArrayContainer Interface | © 1992-2002 Mjølner Informatics |
[Modified: Tuesday January 11th 2000 at 16:33]
|