Index: src/OFArray.h ================================================================== --- src/OFArray.h +++ src/OFArray.h @@ -88,19 +88,24 @@ * \return The objects of the array as a C array */ - (id*)cArray; /** - * Returns a specific object of the OFDataArray. + * Returns a specific object of the OFArray. * * \param index The number of the object to return * \return The specified object of the OFArray */ - (id)objectAtIndex: (size_t)index; /** - * \return The last object of the OFDataArray + * \return The first object of the OFArray or nil + */ +- (id)firstObject; + +/** + * \return The last object of the OFArray or nil */ - (id)lastObject; - addObject: (OFObject*)obj; - removeObjectAtIndex: (size_t)index; Index: src/OFArray.m ================================================================== --- src/OFArray.m +++ src/OFArray.m @@ -169,10 +169,17 @@ - (id)objectAtIndex: (size_t)index { return *((OFObject**)[array itemAtIndex: index]); } + +- (id)firstObject +{ + void *first = [array firstItem]; + + return (first != NULL ? *((id*)first) : nil); +} - (id)lastObject { void *last = [array lastItem]; Index: src/OFDataArray.h ================================================================== --- src/OFDataArray.h +++ src/OFDataArray.h @@ -72,11 +72,16 @@ * \return The specified item of the OFDataArray */ - (void*)itemAtIndex: (size_t)index; /** - * \return The last item of the OFDataArray + * \return The first item of the OFDataArray or NULL + */ +- (void*)firstItem; + +/** + * \return The last item of the OFDataArray or NULL */ - (void*)lastItem; /** * Adds an item to the OFDataArray. Index: src/OFDataArray.m ================================================================== --- src/OFDataArray.m +++ src/OFDataArray.m @@ -77,10 +77,18 @@ if (index >= count) @throw [OFOutOfRangeException newWithClass: isa]; return data + index * itemsize; } + +- (void*)firstItem +{ + if (data == NULL || count == 0) + return NULL; + + return data; +} - (void*)lastItem { if (data == NULL || count == 0) return NULL;