IntegerArray.m
author Jens Alfke <jens@mooseyard.com>
Wed Sep 02 08:41:25 2009 -0700 (2009-09-02)
changeset 35 5cab3034d3a1
permissions -rw-r--r--
10.6 compatibility: Fix some new compiler warnings, and work around apparent regressions in NSTask and -stringByStandardizingPath.
     1 //
     2 //  IntegerArray.m
     3 //  Cloudy
     4 //
     5 //  Created by Jens Alfke on 6/23/08.
     6 //  Copyright 2008 Jens Alfke. All rights reserved.
     7 //
     8 
     9 #import "IntegerArray.h"
    10 
    11 
    12 @implementation IntegerArray
    13 
    14 - (id) init
    15 {
    16     self = [super init];
    17     if (self != nil) {
    18         _storage = [[NSMutableData alloc] initWithCapacity: 10*sizeof(SInt32)];
    19     }
    20     return self;
    21 }
    22 
    23 - (void) dealloc
    24 {
    25     [_storage release];
    26     [super dealloc];
    27 }
    28 
    29 
    30 
    31 - (NSUInteger)count             {return _count;}
    32 - (const SInt32*) allIntegers   {return _integers;}
    33 
    34 - (SInt32) integerAtIndex: (NSUInteger)index
    35 {
    36     Assert(index<_count);
    37     return _integers[index];
    38 }
    39 
    40 - (void) setInteger: (SInt32)value atIndex: (NSUInteger)index
    41 {
    42     Assert(index<_count);
    43     _integers[index] = value;
    44 }
    45 
    46 - (void) addInteger: (SInt32)value
    47 {
    48     [_storage appendBytes: &value length: sizeof(value)];
    49     _count++;
    50     _integers = [_storage mutableBytes];
    51 }
    52 
    53 @end