00001 /* 00002 * Copyright (c) 2008, 2009, 2010, 2011 00003 * Jonathan Schleifer <js@webkeks.org> 00004 * 00005 * All rights reserved. 00006 * 00007 * This file is part of ObjFW. It may be distributed under the terms of the 00008 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in 00009 * the packaging of this file. 00010 * 00011 * Alternatively, it may be distributed under the terms of the GNU General 00012 * Public License, either version 2 or 3, which can be found in the file 00013 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this 00014 * file. 00015 */ 00016 00017 #import "OFObject.h" 00018 #import "OFCollection.h" 00019 #import "OFEnumerator.h" 00020 00021 typedef struct of_list_object_t of_list_object_t; 00028 struct of_list_object_t { 00030 of_list_object_t *next; 00032 of_list_object_t *prev; 00034 id object; 00035 }; 00036 00040 @interface OFList: OFObject <OFCopying, OFCollection, OFFastEnumeration> 00041 { 00042 of_list_object_t *firstListObject; 00043 of_list_object_t *lastListObject; 00044 size_t count; 00045 unsigned long mutations; 00046 } 00047 00048 #ifdef OF_HAVE_PROPERTIES 00049 @property (readonly) of_list_object_t *firstListObject; 00050 @property (readonly) of_list_object_t *lastListObject; 00051 #endif 00052 00056 + list; 00057 00061 - (of_list_object_t*)firstListObject; 00062 00066 - (of_list_object_t*)lastListObject; 00067 00076 - (of_list_object_t*)appendObject: (id)obj; 00077 00086 - (of_list_object_t*)prependObject: (id)obj; 00087 00097 - (of_list_object_t*)insertObject: (id)obj 00098 beforeListObject: (of_list_object_t*)listobj; 00099 00109 - (of_list_object_t*)insertObject: (id)obj 00110 afterListObject: (of_list_object_t*)listobj; 00111 00117 - (void)removeListObject: (of_list_object_t*)listobj; 00118 @end 00119 00120 @interface OFListEnumerator: OFEnumerator 00121 { 00122 of_list_object_t *first; 00123 of_list_object_t *current; 00124 unsigned long mutations; 00125 unsigned long *mutationsPtr; 00126 } 00127 00128 - initWithFirstListObject: (of_list_object_t*)first 00129 mutationsPointer: (unsigned long*)mutations_ptr; 00130 @end