mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-04 10:30:47 +00:00
Add new semantic to ivar _grow_factor: if it is less than 0, the array
grows by -_grow_factor, but never shrinks. (incrementCount): Use the ABS() of _grow_factor. (decrementCount): Only shrink the array if _grow_factor is > 0. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1298 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a1ac8e7aa0
commit
98e317d924
2 changed files with 8 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
||||||
/* Array definitions for the use of subclass implementations only
|
/* Array definitions for the use of subclass implementations only
|
||||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
Copyright (C) 1993, 1994, 1996 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||||
Date: May 1993
|
Date: May 1993
|
||||||
|
@ -69,7 +69,7 @@ incrementCount(Array *self)
|
||||||
(self->_count)++;
|
(self->_count)++;
|
||||||
if (self->_count == self->_capacity)
|
if (self->_count == self->_capacity)
|
||||||
{
|
{
|
||||||
[self setCapacity:(self->_capacity) * self->_grow_factor];
|
[self setCapacity:(self->_capacity) * ABS(self->_grow_factor)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,8 @@ static inline void
|
||||||
decrementCount(Array *self)
|
decrementCount(Array *self)
|
||||||
{
|
{
|
||||||
(self->_count)--;
|
(self->_count)--;
|
||||||
if (self->_count < (self->_capacity) / self->_grow_factor)
|
if (self->_grow_factor > 0
|
||||||
|
&& self->_count < (self->_capacity / self->_grow_factor))
|
||||||
{
|
{
|
||||||
[self setCapacity:(self->_capacity) / self->_grow_factor];
|
[self setCapacity:(self->_capacity) / self->_grow_factor];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* Array definitions for the use of subclass implementations only
|
/* Array definitions for the use of subclass implementations only
|
||||||
Copyright (C) 1993,1994 Free Software Foundation, Inc.
|
Copyright (C) 1993, 1994, 1996 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
Written by: R. Andrew McCallum <mccallum@gnu.ai.mit.edu>
|
||||||
Date: May 1993
|
Date: May 1993
|
||||||
|
@ -69,7 +69,7 @@ incrementCount(Array *self)
|
||||||
(self->_count)++;
|
(self->_count)++;
|
||||||
if (self->_count == self->_capacity)
|
if (self->_count == self->_capacity)
|
||||||
{
|
{
|
||||||
[self setCapacity:(self->_capacity) * self->_grow_factor];
|
[self setCapacity:(self->_capacity) * ABS(self->_grow_factor)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,8 @@ static inline void
|
||||||
decrementCount(Array *self)
|
decrementCount(Array *self)
|
||||||
{
|
{
|
||||||
(self->_count)--;
|
(self->_count)--;
|
||||||
if (self->_count < (self->_capacity) / self->_grow_factor)
|
if (self->_grow_factor > 0
|
||||||
|
&& self->_count < (self->_capacity / self->_grow_factor))
|
||||||
{
|
{
|
||||||
[self setCapacity:(self->_capacity) / self->_grow_factor];
|
[self setCapacity:(self->_capacity) / self->_grow_factor];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue