Skip to content

Instantly share code, notes, and snippets.

@Machx
Forked from anonymous/gist:4392908
Last active December 10, 2015 06:08
Show Gist options
  • Save Machx/4392987 to your computer and use it in GitHub Desktop.
Save Machx/4392987 to your computer and use it in GitHub Desktop.
import Cocoa;
export MyFramework.DataStructures;
//Objective-C Modules
@class Queue : NSObject
//implicitly because we are exporting group names we have a "namespace" of sorts
//which is why this class doesn't have a prefix. Since we have modules now @class
//can serve a different purpose than it currently serves
@property(private,retain) NSMutableArray *storage;
-(public id)init
{
self = [super init];
if(self) {
_storage = [NSMutableArray array];
}
return self;
}
-(public void)enqueue:(id)object
{
NSParameterAssert(object);
[self.storage addObject:object];
}
-(public id)dequeue
{
if(self.storage.count == 0) return nil;
id object = self.storage[0];
[self.storage removeObjectAtIndex:0];
return object;
}
@end
//You could have a default rule that everything is public and
//only have to explicitly mark things as private
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment