diff -r 3eb7be1dd7b6 -r b0affce7beb1 Source/Stack.m --- a/Source/Stack.m Mon Mar 10 17:30:57 2008 -0700 +++ b/Source/Stack.m Tue Mar 10 22:36:23 2009 -0700 @@ -63,6 +63,18 @@ @synthesize bits=_bits; +- (NSUInteger) numberOfBits +{ + return _bits.count; +} + +- (void) setNumberOfBits: (NSUInteger)n +{ + NSAssert2(n<=_bits.count,@"Cannot increase numberOfBits (from %u to %u)", _bits.count,n); + while( _bits.count > n ) + [self removeBit: self.topBit]; +} + - (Bit*) topBit { return [_bits lastObject]; @@ -98,6 +110,16 @@ } +- (void) removeBit: (Bit*)bit +{ + NSUInteger index = [_bits indexOfObjectIdenticalTo: bit]; + if( index != NSNotFound ) { + [bit removeFromSuperlayer]; + [_bits removeObjectAtIndex: index]; + } +} + + - (void) setHighlighted: (BOOL)highlighted { [super setHighlighted: highlighted];