-
-
Save Machx/4392987 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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