diff -r 3eb7be1dd7b6 -r e7a464fb6d39 Source/Stack.m --- a/Source/Stack.m Mon Mar 10 17:30:57 2008 -0700 +++ b/Source/Stack.m Sun Jan 11 00:02:27 2009 -0800 @@ -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];