mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Tidied
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@6479 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
654eda135c
commit
d4ada5920b
4 changed files with 79 additions and 4 deletions
|
@ -168,7 +168,7 @@
|
|||
<standards><GNUstep/><NotOpenStep/><NotMacOS-X/></standards>
|
||||
</function>
|
||||
<function name="GSUPurge" type="void">
|
||||
<arg type="int">count</arg>
|
||||
<arg type="unsigned int">count</arg>
|
||||
<desc>
|
||||
This function purges the global NSCountedSet object used for
|
||||
uniquing. It handles locking as necessary. It can be used to
|
||||
|
@ -176,6 +176,19 @@
|
|||
</desc>
|
||||
<standards><GNUstep/><NotOpenStep/><NotMacOS-X/></standards>
|
||||
</function>
|
||||
<function name="GSUSet" type="void">
|
||||
<arg type="id">anObject</arg>
|
||||
<arg type="unsigned int">count</arg>
|
||||
<desc>
|
||||
This function sets the count for the specified object. If the
|
||||
count for the object is set to zero then the object is removed
|
||||
from the global uniquing set. The object is added to the set
|
||||
if necessary.
|
||||
The function handles locking as necessary. It can be used to
|
||||
alter the set even when uniquing is turned off.
|
||||
</desc>
|
||||
<standards><GNUstep/><NotOpenStep/><NotMacOS-X/></standards>
|
||||
</function>
|
||||
</chapter>
|
||||
</body>
|
||||
</gsdoc>
|
||||
|
|
|
@ -186,12 +186,23 @@ Standards: NotOpenStep NotMacOS-X<br>
|
|||
|
||||
<hr>
|
||||
<h2><a name="function-13">GSUPurge</a></h2>
|
||||
<b>Prototype:</b> void GSUPurge(int count)<br>
|
||||
<b>Prototype:</b> void GSUPurge(unsigned int count)<br>
|
||||
|
||||
This function purges the global NSCountedSet object used for
|
||||
uniquing. It handles locking as necessary. It can be used to
|
||||
purge the set even when uniquing is turned off.
|
||||
|
||||
<hr>
|
||||
<h2><a name="function-14">GSUSet</a></h2>
|
||||
<b>Prototype:</b> void GSUSet(id anObject, unsigned int count)<br>
|
||||
|
||||
This function sets the count for the specified object. If the
|
||||
count for the object is set to zero then the object is removed
|
||||
from the global uniquing set. The object is added to the set
|
||||
if necessary.
|
||||
The function handles locking as necessary. It can be used to
|
||||
alter the set even when uniquing is turned off.
|
||||
|
||||
<hr>
|
||||
</body>
|
||||
|
||||
|
|
|
@ -119,8 +119,15 @@ id GSUnique(id anObject);
|
|||
|
||||
/*
|
||||
* Management functions -
|
||||
*
|
||||
* GSUPurge() can be used to purge infrequently referenced objects from the
|
||||
* set by removing any objec whose count is less than or equal to that given.
|
||||
*
|
||||
* GSUSet() can be used to artificially set the count for a particular object
|
||||
* Setting the count to zero will remove the object from the global set.
|
||||
*/
|
||||
void GSUPurge(int count); /* Purge infrequently referenced objs */
|
||||
void GSUPurge(unsigned count);
|
||||
void GSUSet(id anObject, unsigned count);
|
||||
|
||||
#include <base/KeyedCollecting.h>
|
||||
|
||||
|
|
|
@ -223,7 +223,7 @@ static Class NSCountedSet_concrete_class;
|
|||
|
||||
|
||||
void
|
||||
GSUPurge(int level)
|
||||
GSUPurge(unsigned level)
|
||||
{
|
||||
if (uniqueLock != nil)
|
||||
{
|
||||
|
@ -236,6 +236,50 @@ GSUPurge(int level)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
GSUSet(id obj, unsigned level)
|
||||
{
|
||||
id found;
|
||||
unsigned i;
|
||||
|
||||
if (uniqueLock != nil)
|
||||
{
|
||||
(*lockImp)(uniqueLock, @selector(lock));
|
||||
}
|
||||
found = [uniqueSet member: obj];
|
||||
if (found == nil)
|
||||
{
|
||||
for (i = 0; i < level; i++)
|
||||
{
|
||||
[uniqueSet addObject: obj];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
i = [uniqueSet countForObject: obj];
|
||||
if (i < level)
|
||||
{
|
||||
while (i < level)
|
||||
{
|
||||
[uniqueSet addObject: obj];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else if (i > level)
|
||||
{
|
||||
while (i > level)
|
||||
{
|
||||
[uniqueSet removeObject: obj];
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (uniqueLock != nil)
|
||||
{
|
||||
(*unlockImp)(uniqueLock, @selector(unlock));
|
||||
}
|
||||
}
|
||||
|
||||
id
|
||||
GSUnique(id obj)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue