Files
TaskExplorer/NSMutableArray+QueueAdditions.m
T
Patrick Wardle 205e24d309 version 2.0.0
-avoid UI calls when run in cmdline mode
 -hide icon when run in cmdline mode
 -option to scan single process
2018-12-21 20:19:09 -10:00

55 lines
983 B
Objective-C

//
// NSMutableArray+QueueAdditions.m
// BlockBlock
//
// Created by Patrick Wardle on 9/26/14.
// Copyright (c) 2014 Objective-See. All rights reserved.
//
#import "NSMutableArray+QueueAdditions.h"
@implementation NSMutableArray (QueueAdditions)
//add object to tail (end) of queue
-(void)enqueue:(id)anObject
{
//sync
@synchronized(self)
{
//add object
[self addObject:anObject];
}
}
//grab next item in queue
-(id)dequeue
{
//extract object
id queueObject = nil;
//sync
@synchronized(self)
{
//check to make sure there are some items
if(YES != [self empty])
{
//extract first one
queueObject = [self objectAtIndex: 0];
//delete it from queue
[self removeObjectAtIndex: 0];
}
}//sync
return queueObject;
}
// Checks if the queue is empty
-(BOOL)empty
{
return ([self lastObject] == nil);
}
@end