28 + (id)indexPathWithIndex:(
int)index
30 return [[
self alloc] initWithIndexes:[index] length:1];
33 + (id)indexPathWithIndexes:(CPArray)indexes length:(
int)length
35 return [[
self alloc] initWithIndexes:indexes length:length];
38 + (id)indexPathWithIndexes:(CPArray)indexes
40 return [[
self alloc] initWithIndexes:indexes];
43 - (id)initWithIndexes:(CPArray)indexes length:(
int)length
48 _indexes = [
indexes subarrayWithRange:CPMakeRange(0, length)];
53 - (id)initWithIndexes:(CPArray)indexes
65 return [
super description] +
" " + _indexes;
69 #pragma mark Accessing
73 return [_indexes count];
76 - (int)indexAtPosition:(
int)position
78 return [_indexes objectAtIndex:position];
81 - (void)setIndexes:(CPArray)theIndexes
83 _indexes = [theIndexes copy];
88 return [_indexes copy];
92 #pragma mark Modification
105 #pragma mark Comparison
109 if (anObject ===
self)
115 return [_indexes isEqualToArray:[anObject indexes]];
123 var lhsIndexes = [
self indexes],
124 rhsIndexes = [anIndexPath
indexes],
125 lhsCount = [lhsIndexes count],
126 rhsCount = [rhsIndexes count];
129 count = MIN(lhsCount, rhsCount);
131 for (; index < count; ++index)
133 var lhs = lhsIndexes[index],
134 rhs = rhsIndexes[index];
143 if (lhsCount === rhsCount)
146 if (lhsCount === count)
160 if (
self = [
self init])
162 _indexes = [theCoder decodeObjectForKey:CPIndexPathIndexesKey];
170 [theCoder encodeObject:_indexes forKey:CPIndexPathIndexesKey];
188 - (void)setIndexes:(CPArray)aValue