forked from KOed/welly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WLIntegerArray.m
63 lines (48 loc) · 1.01 KB
/
WLIntegerArray.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// XIIntegerArray.m
// Welly
//
// Created by boost on 7/28/08.
// Copyright 2008 Xi Wang. All rights reserved.
//
#import "WLIntegerArray.h"
@implementation WLIntegerArray
+ integerArray {
return [[[WLIntegerArray alloc] init] autorelease];
}
- (id)init {
if (self = [super init]) {
[self clear];
}
return self;
}
- (void)dealloc {
[_array release];
[super dealloc];
}
- (void)push_back:(NSInteger)integer {
[_array addPointer:(void *)integer];
}
- (void)pop_front {
[_array removePointerAtIndex:0];
}
- (NSInteger)at:(NSUInteger)index {
return (NSInteger)[_array pointerAtIndex:index];
}
- (void)set:(NSInteger)value at:(NSUInteger)index {
[_array replacePointerAtIndex:index withPointer:(void *)value];
}
- (NSInteger)front {
return [self at:0];
}
- (BOOL)empty {
return [_array count] == 0;
}
- (NSUInteger)size {
return [_array count];
}
- (void)clear {
[_array release];
_array = [[NSPointerArray pointerArrayWithWeakObjects] retain];
}
@end