home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR9
/
WIZTOO.ZIP
/
CHANNEL.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-09-18
|
1KB
|
58 lines
// Module: CHANNEL.CPP
#include <stdio.h>
#include "CHANNEL.H"
int Channel::Add (void *opReceiver)
{
if (iNumInList >= MAXRECEIVERS) return (iStatus=CHANNEL_CONNECT_FAIL);
opList[iNumInList++] = opReceiver;
return (iStatus=(iNumInList==0) ? CHANNEL_EMPTY : CHANNEL_OK);
}
int Channel::Find (void *opReceiver)
{
if (iNumInList < 1) return -1;
for (int i=0; i<iNumInList; i++)
if (opList[i] == opReceiver) return i;
return -1; // -1 indicates no entry found
}
void Channel::Remove (int idx)
{
if (iNumInList < 1) return; // verify that idx is a valid
if (idx < 0) return; // index into the current list
if (idx > iNumInList-1) return;
for (int i=idx; i<iNumInList-1; i++)
opList[i] = opList[i+1];
iNumInList--;
return;
}
int Channel::Delete (void *opReceiver)
{
int idx;
if ((idx=Find(opReceiver)) < 0) return (iStatus=CHANNEL_DISCONNECT_FAIL);
Remove(idx);
return (iStatus=(iNumInList==0) ? CHANNEL_EMPTY : CHANNEL_OK);
}
void *Channel::First (void)
{
if (iNumInList < 1) return NULL;
return opList[iTerate=0];
}
void *Channel::Next (void)
{
if (iTerate >= (iNumInList-1)) return NULL;
return opList[++iTerate];
}