Differences From Artifact [18ec5ebfcc]:
- File
src/OFList.m
— part of check-in
[bbf1f79b8f]
at
2009-09-08 16:06:10
on branch trunk
— New OFDictionary implementation and removal of a hack in OFList.
The new implementation is easier to use as it does automatic resizing,
but therefore it's not realtime-capable anymore. The new implementation
should also be a little bit faster.I decided to change the implementation as only very few need a
realtime-capable dictionary and those few will most likely write their
own implementation for their specific case anyway.As the new implementation no longer uses OFList, this also made it
possible to remove a hack from OFList. (user: js, size: 3923) [annotate] [blame] [check-ins using]
To Artifact [b22035331b]:
- File src/OFList.m — part of check-in [a99f512a4a] at 2009-09-16 16:22:27 on branch trunk — Rework OFAutoreleasePool and remove now unnecessary hack from OFList. (user: js, size: 3543) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
22 23 24 25 26 27 28 | return [[[self alloc] init] autorelease]; } - init { self = [super init]; | < < < < < < < < < < < | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | return [[[self alloc] init] autorelease]; } - init { self = [super init]; first = NULL; last = NULL; return self; } - (void)dealloc |
︙ | ︙ | |||
77 78 79 80 81 82 83 | last = o; if (first == NULL) first = o; count++; | < | | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | last = o; if (first == NULL) first = o; count++; [obj retain]; return o; } - (of_list_object_t*)prepend: (id)obj { of_list_object_t *o; |
︙ | ︙ | |||
101 102 103 104 105 106 107 | first = o; if (last == NULL) last = o; count++; | < | | 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | first = o; if (last == NULL) last = o; count++; [obj retain]; return o; } - (of_list_object_t*)insert: (id)obj before: (of_list_object_t*)listobj { |
︙ | ︙ | |||
127 128 129 130 131 132 133 | listobj->prev = o; if (listobj == first) first = o; count++; | < | | 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | listobj->prev = o; if (listobj == first) first = o; count++; [obj retain]; return o; } - (of_list_object_t*)insert: (id)obj after: (of_list_object_t*)listobj { |
︙ | ︙ | |||
153 154 155 156 157 158 159 | listobj->next = o; if (listobj == last) last = o; count++; | < | < | | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | listobj->next = o; if (listobj == last) last = o; count++; [obj retain]; return o; } - remove: (of_list_object_t*)listobj { if (listobj->prev != NULL) listobj->prev->next = listobj->next; if (listobj->next != NULL) listobj->next->prev = listobj->prev; if (first == listobj) first = listobj->next; if (last == listobj) last = listobj->prev; count--; [listobj->object release]; [self freeMemory: listobj]; return self; } - (size_t)count |
︙ | ︙ | |||
209 210 211 212 213 214 215 | assert(iter == NULL && iter2 == NULL); return YES; } - (id)copy { | | < < < < < < | | 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | assert(iter == NULL && iter2 == NULL); return YES; } - (id)copy { OFList *new = [[OFList alloc] init]; of_list_object_t *iter, *o, *prev; o = NULL; prev = NULL; @try { for (iter = first; iter != NULL; iter = iter->next) { o = [new allocMemoryWithSize: sizeof(of_list_object_t)]; o->object = iter->object; o->next = NULL; o->prev = prev; if (new->first == NULL) new->first = o; if (prev != NULL) prev->next = o; new->count++; [o->object retain]; prev = o; } } @catch (OFException *e) { [new release]; @throw e; } new->last = o; return new; } @end |