Source

DTFoundation / DTFoundation / DTQueue.m

Full commit
//
//  DTQueue.m
//  DTFoundation
//
//  Created by Daniel Tull on 05.04.2009.
//  Copyright 2009 Daniel Tull. All rights reserved.
//

#import "DTQueue.h"


@implementation DTQueue

- (id)init {
	
	if (!(self = [super init])) return nil;
	
	queue = [[NSMutableArray alloc] init];
	
	return self;
}

- (void)dealloc {
	[queue release];
	[super dealloc];
}

- (NSUInteger)count {
	return [queue count];
}

- (void)enqueue:(id)object {
	[queue addObject:object];
}

- (void)push:(id)object {
	[self enqueue:object];
}

- (id)dequeue {
	id object = [[queue objectAtIndex:0] retain];
	[queue removeObjectAtIndex:0];
	return [object autorelease];
}

- (id)pop {
	return [self dequeue];
}

- (id)front {
	return [[[queue objectAtIndex:0] retain] autorelease];
}

@end