@@ -40,11 +40,19 @@ /*! * @class OFList OFList.h ObjFW/OFList.h * * @brief A class which provides easy to use double-linked lists. */ -@interface OFList: OFObject +#ifdef OF_HAVE_GENERICS +@interface OFList : +#else +# ifndef DOXYGEN +# define ObjectType id +# endif +@interface OFList: +#endif + OFObject { of_list_object_t *_firstListObject; of_list_object_t *_lastListObject; size_t _count; unsigned long _mutations; @@ -82,21 +90,21 @@ * @param object The object to append * @return An of_list_object_t, needed to identify the object inside the list. * For example, if you want to remove an object from the list, you need * its of_list_object_t. */ -- (of_list_object_t*)appendObject: (id)object; +- (of_list_object_t*)appendObject: (ObjectType)object; /*! * @brief Prepends an object to the list. * * @param object The object to prepend * @return An of_list_object_t, needed to identify the object inside the list. * For example, if you want to remove an object from the list, you need * its of_list_object_t. */ -- (of_list_object_t*)prependObject: (id)object; +- (of_list_object_t*)prependObject: (ObjectType)object; /*! * @brief Inserts an object before another list object. * * @param object The object to insert @@ -104,11 +112,11 @@ * be inserted * @return An of_list_object_t, needed to identify the object inside the list. * For example, if you want to remove an object from the list, you need * its of_list_object_t. */ -- (of_list_object_t*)insertObject: (id)object +- (of_list_object_t*)insertObject: (ObjectType)object beforeListObject: (of_list_object_t*)listObject; /*! * @brief Inserts an object after another list object. * @@ -117,54 +125,73 @@ * inserted * @return An of_list_object_t, needed to identify the object inside the list. * For example, if you want to remove an object from the list, you need * its of_list_object_t. */ -- (of_list_object_t*)insertObject: (id)object +- (of_list_object_t*)insertObject: (ObjectType)object afterListObject: (of_list_object_t*)listObject; /*! * @brief Removes the object with the specified list object from the list. * * @param listObject The list object returned by append / prepend */ - (void)removeListObject: (of_list_object_t*)listObject; +/*! + * @brief Checks whether the list contains an object equal to the specified + * object. + * + * @param object The object which is checked for being in the list + * @return A boolean whether the list contains the specified object + */ +- (bool)containsObject: (ObjectType)object; + /*! * @brief Checks whether the list contains an object with the specified address. * * @param object The object which is checked for being in the list * @return A boolean whether the list contains an object with the specified - * address. + * address + */ +- (bool)containsObjectIdenticalTo: (ObjectType)object; + +/*! + * @brief Returns an OFEnumerator to enumerate through all objects of the list. + * + * @returns An OFEnumerator to enumerate through all objects of the list */ -- (bool)containsObjectIdenticalTo: (id)object; +- (OFEnumerator OF_GENERIC(ObjectType)*)objectEnumerator; /*! * @brief Returns the first object of the list or nil. * * @warning The returned object is *not* retained and autoreleased for * performance reasons! * * @return The first object of the list or nil */ -- (id)firstObject; +- (ObjectType)firstObject; /*! * @brief Returns the last object of the list or nil. * * @warning The returned object is *not* retained and autoreleased for * performance reasons! * * @return The last object of the list or nil */ -- (id)lastObject; +- (ObjectType)lastObject; /*! * @brief Removes all objects from the list. */ - (void)removeAllObjects; @end +#if !defined(OF_HAVE_GENERICS) && !defined(DOXYGEN) +# undef ObjectType +#endif @interface OFListEnumerator: OFEnumerator { OFList *_list; of_list_object_t *_current;