Created
August 19, 2012 07:33
-
-
Save hadashiA/3393294 to your computer and use it in GitHub Desktop.
Objective-cでutlistつかう。 単方向リスト
This file contains hidden or 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <Foundation/Foundation.h> | |
#include "utlist.h" | |
@interface Enemy : NSObject | |
@end | |
@implementation Enemy | |
@end | |
typedef struct enemy_waiting { | |
Enemy *enemy; | |
struct enemy_waiting *next; | |
} enemy_waiting; | |
int main(int argc, char **argv) { | |
enemy_waiting *head = NULL; | |
int i; | |
for (i = 0; i < 10; ++i) { | |
enemy_waiting *waiting = malloc(sizeof(enemy_waiting)); | |
waiting->enemy = [[Enemy alloc] init]; | |
NSLog(@"append -> %@\n", waiting->enemy); | |
LL_APPEND(head, waiting); | |
} | |
printf("-------\n"); | |
enemy_waiting *iter; | |
LL_FOREACH(head, iter) { | |
NSLog(@"%@", iter->enemy); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment