swarm-support
[Top][All Lists]
Advanced

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

Implementing Frequency Lists.


From: William S. Shu
Subject: Implementing Frequency Lists.
Date: Tue, 30 Mar 1999 15:55:42 +0100

Please for assistance.  My problem can be abstractly described as follows:

I want to create a frequency list.  It is like any other list except that a
count is also kept of the number of times each element occurs.  This count
is incremented/decremented if existing elements are added/deleted.  The
entry is deleted if count is <= zero, and a new entry made if item is not in
the list.

To implement this, I use a swarm-defined list object, and add entries via a
frequencyCell object given by:

@interface FrequencyCell:swarmObject
{
    int  tally;                    // frequency of occurence of object.
    id item;                       // pointer to object
}
...
@end

Thus, to get at an item, I search the list to get its frequencyCell, then
access its id.  The first observation is that this is rather inefficient (C
background surfacing?)  I have to write code to do the search etc., when I
would have used List facilities to access the object!  (Tried to use
MapIndex, but I do not seem to get the hang of it).  My first question is:
Is there a simpler way of doing this?  If so, how is it done?

Now, in order to implement the list, I define a class like below:

@interface FrequencyClusters:swarmObject<List>
...
@end

FrequencyClusters has only additional methods (but no variables).  The
trouble is that swarm wants me to provide methods for the <List> protocol.
When I remove the <List> protocol requirement, it complains about methods
not found, and would not accept List as a super-object.  Now, I have been
using Lists and list protocols without implementing its methods.  I presume
the methods are inherited or swarm implements them for me.

My second question then is: How do I inherit (or acquire)
existing/implemented methods of the List protocol?  In other words, how can
I use existing/implemented protocols of swarm.

------



                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]