[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Implementing Frequency Lists.
From: |
Paul E. Johnson |
Subject: |
Re: Implementing Frequency Lists. |
Date: |
Tue, 30 Mar 1999 10:01:08 -0600 |
"William S. Shu" wrote:
>
> Please for assistance. My problem can be abstractly described as follows:
>
> I want to create a frequency list.
>
Benedikt S told me how to do this last year.
First, create a new class, say called "Frequency_Indicator". Iniside
there, create an instance variable
int total;
And methods such as
-addOne
{
total++;
return self;
}
-(int)getTotal
{
return total;
}
(Note I'm not using the word Count because it is used in the swarm
library and a method you might have, like, "getCount" could cause a
clash with the built in method in Lists, I recall).
Next, suppose you have N categories. Make a swarm array of N catetories:
anArray=[Array create: [self getZone] setCount:N];
(This is off the top of my head, so double check syntax in manual).
Then create N instances of the Frequency_Indicator Class, and put each
one into position in the Array. Then when you want to augment the
Frequency_Indicator in position k, you get the k'th element of anArray
and tell that object to addOne, as in
[[anArray atOffset: k] addOne];
And to retrieve that, you replace addOne with "getTotal".
> 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.
You can't subclass from the List protocols, you can only use them. If
you need enhancements, you have options, such as write a new class, of
type "SwarmObject", say, that has a list in it and then enhance that new
class to do what you want.
>
> ------
>
> ==================================
> 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.
--
Paul E. Johnson email: address@hidden
Dept. of Political Science http://lark.cc.ukans.edu/~pauljohn
University of Kansas Office: (785) 864-9086
Lawrence, Kansas 66045 FAX: (785) 864-5700
==================================
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.