[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ADT Lib (4.2) (is it 5 now?)



Hi there!

At 10:09 PM -0400 6/11/98, Ian Rae wrote:

>Add/Remove methods for Container:
>----------------------------------------------------
>I'm not sure why these can't be included.  Even set ADTs have Add and
>Remove operations.  Are there ADT's that don't?
>
>The semantics would be:
>
>PROCEDURE (c: Container) Add* (obj: AcObject.Object);
>(* Ensures obj becomes a member of the container.
>The size of the container may or may not change.
>eg. for Sets this method will do nothing if obj is already in c.
>ADTs that allow multiple copies of same object in the container
>would always add obj to the container.
>*)
>
>PROCEDURE (c: Container) Remove* (obj: AcObject.Object);
>(* Ensures that the membership count of obj in c is decremented
>by one.  If obj was in c once, then it is removed.  If obj was in
>c multiple times, then one copy of obj is removed (with no guaruntee
>of which copy gets removed).  If obj is not in c then nothing is done.
>*)

   Okay, what about Hashtables, AVL-Trees or other data structures that
actually require the "elements" stored within to support a certain set of
operations like Hash(): INTEGER or LessThan (other: Ordered): BOOLEAN? I
have repeatedly stated my opinion that a generic Container-like base class
can only have "undisputable" methods like Empty(): BOOLEAN or Elements():
INTEGER. Nothing else.

By(T)e...        /  Department of Information and Computer Science  \
        Peter... \ University of California - Irvine, CA 92697-3425 /