This is Storage.h in view mode; [Download] [Up]
/* Interface for Objective C NeXT-compatible Storage object
Copyright (C) 1993 R. Andrew McCallum <mccallum@cs.rochester.edu>
Dept. of Computer Science, U. of Rochester, Rochester, NY 14627
Copyright (C) 1993 Kresten Krab Thorup <krab@iesd.auc.dk>
Dept. of Mathematics and Computer Science, Aalborg U., Denmark
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/******************************************************************
TODO:
Does not implement methods for archiving itself.
******************************************************************/
#ifndef __Storage_h_INCLUDE_GNU
#define __Storage_h_INCLUDE_GNU
#include <objc/Object.h>
@interface Storage : Object
{
@public
void **dataPtr; /* data of the Storage object */
unsigned numElements; /* Actual number of elements */
unsigned maxElements; /* Total allocated elements */
const char *description; /* Element description */
unsigned elementSize; /* Element size */
}
/* Creating, copying, freeing */
- free;
- shallowCopy;
/* Initializing */
- init;
- initCount:(unsigned)numSlots
elementSize:(unsigned)sizeInBytes
description:(const char*)elemDesc;
- setNumSlots: (unsigned)numSlots;
/* Comparing two storages */
- (BOOL)isEqual: anObject;
/* Managing the storage capacity */
- (unsigned)capacity;
- setAvailableCapacity:(unsigned)numSlots;
/* Manipulating objects by index */
- (unsigned)count;
- (void*)elementAt:(unsigned)index;
- (void*)lastElement;
- addElement:(void*)anElement;
- insertElement:(void*)anElement at:(unsigned)index;
- removeElementAt:(unsigned)index;
- (void*)removeLastElement;
- replaceElementAt:(unsigned)index with:(void*)newElement;
- appendStorage: (Storage*)otherStorage;
/* Manipulating elements by id */
- (unsigned)indexOf:(void*)anElement;
- addElementIfAbsent:(void*)anElement;
- removeElement:(void*)anElement;
- replaceElement:(void*)anElement with:(void*)newElement;
/* Emptying the storage */
- empty;
/* Sorting */
/* aSel must be typed like: -(int)compare:(id)o1 :(id)o2 */
- sortUsingFunction:(int(*)(void*,void*))comparisonFunction;
@end
typedef struct {
@defs(Storage)
} GNUStorageId;
#define GNU_STORAGE_ADDRESS(x) (((GNUStorageId *)(x))->dataPtr)
#define GNU_STORAGE_NTH(x,N) \
({ GNUStorageId* __s=(GNUStorageId*)(x); \
(void*)(((char*)__s->dataPtr)+(__s->elementSize*(N))); })
#define GNU_NOT_IN_STORAGE 0xffffffff
#define GNU_FORSTORAGE(storage, element) \
{ int _GNU_FORSTORAGE_i; \
GNUStorageId* _GNU_FORSTORAGE_s = (GNUStorageId *)(storage); \
for (_GNU_FORSTORAGE_i = 0; \
_GNU_FORSTORAGE_i < (_GNU_FORSTORAGE_s->numElements); \
_GNU_FORSTORAGE_i++) \
{ \
element = GNU_STORAGE_NTH (_GNU_FORSTORAGE_s, _GNU_FORSTORAGE_i)
#define GNU_ENDFORSTORAGE }}
#endif /* __Storage_h_INCLUDE_GNU */
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.