mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +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
ef2a25f184
commit
7867d0a082
2 changed files with 8 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
|||
/* 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>
|
||||
Date: May 1993
|
||||
|
@ -69,7 +69,7 @@ incrementCount(Array *self)
|
|||
(self->_count)++;
|
||||
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)
|
||||
{
|
||||
(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];
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* 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>
|
||||
Date: May 1993
|
||||
|
@ -69,7 +69,7 @@ incrementCount(Array *self)
|
|||
(self->_count)++;
|
||||
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)
|
||||
{
|
||||
(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];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue