1// 2// KTMatrixDenseEnumerator 3// KTMatrix collection class cluster 4// 5// Enumerator classes for the dense implementations of KTMatrix 6// 7// Copyright (c) 2002 Chris Purcell. All rights reserved. 8// 9// You may use this code for whatever purposes you wish. 10// This code comes with no warranties, implied or otherwise. 11// Using it may damage your data. It shouldn't, but save a copy first. 12// That's a good idea anyway, actually. 13// 14 15#import "KTMatrixDenseEnumerator.h" 16 17 18@implementation KTMatrixDenseEnumerator 19 20- (id)initWithArray:(const id *)_ar 21 ofCapacity:(unsigned)_ca 22 collection:(id)collection; 23{ 24 if ((self = [super init])) 25 { 26 array = _ar; 27 broken = NO; 28 capacity = _ca; 29 offset = 0; 30 source = [collection retain]; 31 } 32 return self; 33} 34- (id)nextObject 35{ 36 if (broken && (offset < capacity)) 37 offset++; 38 while ((offset < capacity) && (array[offset] == NULL)) 39 offset++; 40 broken = YES; 41 if (offset < capacity) 42 return array[offset]; 43 else 44 return NULL; 45} 46- (unsigned)hashedLocation 47{ return offset; } 48 49- (void)dealloc 50{ 51 [source release]; 52 [super dealloc]; 53} 54 55@end 56