home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
PtrSet.cxx
< prev
next >
Wrap
C/C++ Source or Header
|
1996-05-31
|
2KB
|
81 lines
/*---------------------------------------------------------------------------
*
* Copyright (c) 1993 by Westmount Technology B.V., Delft, The Netherlands.
*
* This software is furnished under a license and may be used only in
* accordance with the terms of such license and with the inclusion of
* the above copyright notice. This software or any other copies thereof
* may not be provided or otherwise made available to any other person.
* No title to and ownership of the software is hereby transferred.
*
* The information in this software is subject to change without notice
* and should not be construed as a commitment by Westmount Technology B.V.
*
*---------------------------------------------------------------------------
*
* File : @(#)PtrSet.cxx 1.3
* Author : frmo
* Original date : 26-2-1993
* Description : Set of Pointers
*
*---------------------------------------------------------------------------
*/
static const char SccsId[]="@(#)PtrSet.cxx 1.3 13 Jan 1994 Copyright 1993 Westmount Technology";
#ifndef PTRSET_HXX
#include "PtrSet.hxx"
#endif
PointerHash::~PointerHash()
{
}
unsigned PointerHash::hash() const
{
const ALIGNMENT = 4;
return unsigned(ptr) / ALIGNMENT;
}
int PointerHash::isEqual(const Hashable &key) const
{
return ((const PointerHash &) key).ptr == ptr;
}
int GenPtrSet::add(void *ptr)
{
PointerHash *nph = new PointerHash(ptr);
if (PtrHashTbl::add(*nph) != nph) {
// entry already present
delete nph;
return -1;
}
return 0;
}
void GenPtrSet::remove(void *ptr)
{
delete PtrHashTbl::remove(ptr);
}
int GenPtrSet::isPresent(void *ptr) const
{
return PtrHashTbl::find(ptr) != 0;
}
unsigned GenPtrSet::size() const
{
return PtrHashTbl::size();
}
void *GenPtrSet::first()
{
PointerHash *ph = PtrHashTbl::first();
return ph ? ph->getPtr() : 0;
}
void *GenPtrSet::next()
{
PointerHash *ph = PtrHashTbl::next();
return ph ? ph->getPtr() : 0;
}