diff --git a/MathPad/MPExpression.h b/MathPad/MPExpression.h index 8d4d821..7f062ea 100644 --- a/MathPad/MPExpression.h +++ b/MathPad/MPExpression.h @@ -442,18 +442,75 @@ */ - (void)appendElements:(NSArray *)elements; -- (void)insertElement:(id)anElement atLocation:(NSUInteger)index; -- (void)insertElements:(NSArray *)elements atLocation:(NSUInteger)index; +/*! + @method insertElement:atLocation: + @brief Inserts @c anElement at @c location. + + @discussion The location is specified in the length reference frame. + + If the given location exceeds the receiver's bounds a @c + NSRangeException is raised. + + @param anElement + The element to be inserted into the receiver. + + @param location + The location @c anElement should be inserted at. + */ +- (void)insertElement:(id)anElement + atLocation:(NSUInteger)location; + + +/*! + @method insertElements:atLocation: + @brief Inserts the elements from @c elements at @c location. + + @discussion The location is specified in the length reference frame. + + If the given location exceeds the receiver's bounds a @c + NSRangeException is raised. + + @param elements + The elements to be inserted into the receiver. + + @param location + The location the elements in @c elements should be inserted into + the receiver. + */ +- (void)insertElements:(NSArray *)elements + atLocation:(NSUInteger)location; + + +/*! + @method deleteElementsInRange: + @brief Removes the elements specified by @c range from the receiver. + + @discussion The range is specified in the length reference frame. + + If @c range exceeds the receiver's bounds a @c NSRangeException + is raised. + + @param range + The range to remove from the receiver. + */ - (void)deleteElementsInRange:(NSRange)range; -#pragma mark Evaluating Expressions -- (float)floatValue; -- (int)intValue; -- (NSInteger)integerValue; -- (long long)longLongValue; #pragma mark Querying Expressions + + +/*! + @method elements + @brief Returns an array of all elements in the receiver. + + @discussion The elements in the returned array are not copied before they are + returned. + + @return An array of all elements from the receiver. + */ - (NSArray *)elements; +// TODO: - (NSMutableArray *)mutableElements; + @end diff --git a/MathPad/MPExpression.m b/MathPad/MPExpression.m index d427803..5320328 100644 --- a/MathPad/MPExpression.m +++ b/MathPad/MPExpression.m @@ -423,14 +423,16 @@ [self replaceSymbolsInRange:NSMakeRange(self.length, 0) withElements:elements]; } -- (void)insertElement:(id)anElement atLocation:(NSUInteger)index +- (void)insertElement:(id)anElement + atLocation:(NSUInteger)location { - [self insertElements:@[anElement] atLocation:index]; + [self insertElements:@[anElement] atLocation:location]; } -- (void)insertElements:(NSArray *)elements atLocation:(NSUInteger)index +- (void)insertElements:(NSArray *)elements + atLocation:(NSUInteger)location { - [self replaceSymbolsInRange:NSMakeRange(index, 0) withElements:elements]; + [self replaceSymbolsInRange:NSMakeRange(location, 0) withElements:elements]; } - (void)deleteElementsInRange:(NSRange)range @@ -438,25 +440,4 @@ [self replaceSymbolsInRange:range withElements:@[]]; } -#pragma mark Evaluating Expressions -- (float)floatValue -{ - return (float)[self doubleValue]; -} - -- (int)intValue -{ - return (int)[self doubleValue]; -} - -- (NSInteger)integerValue -{ - return (NSInteger)[self doubleValue]; -} - -- (long long)longLongValue -{ - return (long long)[self doubleValue]; -} - @end