New file from Albin Jones

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@910 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Andrew McCallum 1996-02-13 02:35:45 +00:00
parent a2a3de7eec
commit 5d06584d36
31 changed files with 4812 additions and 0 deletions

View file

@ -0,0 +1,113 @@
/* NSHashTable interface for GNUStep.
* Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Mon Dec 12 23:56:03 EST 1994
* Updated: Sat Feb 10 15:55:51 EST 1996
* Serial: 96.02.10.02
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __NSHashTable_h_OBJECTS_INCLUDE
#define __NSHashTable_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
#include <Foundation/NSObject.h>
#include <Foundation/NSString.h>
#include <Foundation/NSArray.h>
#include <objects/hash.h>
/**** Type, Constant, and Macro Definitions **********************************/
typedef objects_hash_t NSHashTable;
typedef objects_hash_enumerator_t NSHashEnumerator;
typedef struct _NSHashTableCallBacks NSHashTableCallBacks;
struct _NSHashTableCallBacks
{
unsigned int (*hash) (NSHashTable *, const void *);
BOOL (*isEqual) (NSHashTable *, const void *, const void *);
void (*retain) (NSHashTable *, const void *);
void (*release) (NSHashTable *, void *);
NSString *(*describe) (NSHashTable *, const void *);
};
extern const NSHashTableCallBacks NSIntHashCallBacks;
extern const NSHashTableCallBacks NSNonOwnedPointerHashCallBacks;
extern const NSHashTableCallBacks NSNonRetainedObjectsHashCallBacks;
extern const NSHashTableCallBacks NSObjectsHashCallBacks;
extern const NSHashTableCallBacks NSOwnedPointerHashCallBacks;
extern const NSHashTableCallBacks NSPointerToStructHashCallBacks;
/**** Function Prototypes ****************************************************/
/** Creating an NSHashTable **/
NSHashTable *NSCreateHashTable (NSHashTableCallBacks callBacks,
unsigned int capacity);
NSHashTable *NSCreateHashTableWithZone (NSHashTableCallBacks callBacks,
unsigned int capacity,
NSZone *zone);
NSHashTable *NSCopyHashTableWithZone (NSHashTable *table, NSZone *zone);
/** Freeing an NSHashTable **/
void NSFreeHashTable (NSHashTable * table);
void NSResetHashTable (NSHashTable * table);
/** Comparing two NSHashTables **/
BOOL NSCompareHashTables (NSHashTable *table1, NSHashTable *table2);
/** Getting the number of items in an NSHashTable **/
unsigned int NSCountHashTable (NSHashTable *table);
/** Retrieving items from an NSHashTable **/
void *NSHashGet (NSHashTable *table, const void *pointer);
NSArray *NSAllHashTableObjects (NSHashTable *table);
NSHashEnumerator NSEnumerateHashTable (NSHashTable *table);
void *NSNextHashEnumeratorItem (NSHashEnumerator *enumerator);
/** Adding an item to an NSHashTable **/
void NSHashInsert (NSHashTable *table, const void *pointer);
void NSHashInsertKnownAbsent (NSHashTable *table, const void *pointer);
void *NSHashInsertIfAbsent (NSHashTable *table, const void *pointer);
/** Removing an item from an NSHashTable **/
void NSHashRemove (NSHashTable *table, const void *pointer);
/** Getting an NSString representation of an NSHashTable **/
NSString *NSStringFromHashTable (NSHashTable *table);
#endif /* __NSHashTable_h_OBJECTS_INCLUDE */

View file

@ -0,0 +1,145 @@
/* NSMapTable interface for GNUStep.
* Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Tue Dec 13 00:05:02 EST 1994
* Updated: Sat Feb 10 15:55:51 EST 1996
* Serial: 96.02.10.02
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __NSMapTable_h_OBJECTS_INCLUDE
#define __NSMaptable_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
#include <Foundation/NSObject.h>
#include <Foundation/NSString.h>
#include <Foundation/NSArray.h>
#include <objects/map.h>
/**** Type, Constant, and Macro Definitions **********************************/
typedef objects_map_t NSMapTable;
typedef objects_map_enumerator_t NSMapEnumerator;
typedef struct _NSMapTableKeyCallBacks NSMapTableKeyCallBacks;
typedef struct _NSMapTableValueCallBacks NSMapTableValueCallBacks;
struct _NSMapTableKeyCallBacks
{
unsigned (*hash) (NSMapTable *, const void *);
BOOL (*isEqual) (NSMapTable *, const void *, const void *);
void (*retain) (NSMapTable *, const void *);
void (*release) (NSMapTable *, void *);
NSString *(*describe) (NSMapTable *, const void *);
const void *notAKeyMarker;
};
struct _NSMapTableValueCallBacks
{
void (*retain) (NSMapTable *, const void *);
void (*release) (NSMapTable *, void *);
NSString *(*describe) (NSMapTable *, const void *);
};
/* FIXME: What to do here? These can't be right. */
#define NSNotAnIntMapKey 0
#define NSNotAPointerMapKey NULL
extern const NSMapTableKeyCallBacks NSIntMapKeyCallBacks;
extern const NSMapTableKeyCallBacks NSNonOwnedPointerMapKeyCallBacks;
extern const NSMapTableKeyCallBacks NSNonOwnedPointerOrNullMapKeyCallBacks;
extern const NSMapTableKeyCallBacks NSNonRetainedObjectMapKeyCallBacks;
extern const NSMapTableKeyCallBacks NSObjectMapKeyCallBacks;
extern const NSMapTableKeyCallBacks NSOwnedPointerMapKeyCallBacks;
extern const NSMapTableValueCallBacks NSIntMapValueCallBacks;
extern const NSMapTableValueCallBacks NSNonOwnedPointerMapValueCallBacks;
extern const NSMapTableValueCallBacks NSObjectMapValueCallBacks;
extern const NSMapTableValueCallBacks NSOwnedPointerMapValueCallBacks;
/**** Function Prototypes ****************************************************/
/** Creating an NSMapTable **/
NSMapTable *NSCreateMapTable (NSMapTableKeyCallBacks keyCallBacks,
NSMapTableValueCallBacks valueCallBacks,
unsigned int capacity);
NSMapTable *NSCreateMapTableWithZone (NSMapTableKeyCallBacks keyCallBacks,
NSMapTableValueCallBacks valueCallbacks,
unsigned int capacity,
NSZone *zone);
NSMapTable *NSCopyMapTableWithZone (NSMapTable *table,
NSZone *zone);
/** Freeing an NSMapTable **/
void NSFreeMapTable (NSMapTable *table);
void NSResetMapTable (NSMapTable *table);
/** Comparing two NSMapTables **/
BOOL NSCompareMapTables (NSMapTable *table1, NSMapTable *table2);
/** Getting the number of items in an NSMapTable **/
unsigned int NSCountMapTable (NSMapTable *table);
/** Retrieving items from an NSMapTable **/
BOOL NSMapMember (NSMapTable *table, const void *key,
void **originalKey, void **value);
void *NSMapGet (NSMapTable *table, const void *key);
NSMapEnumerator NSEnumerateMapTable (NSMapTable *table);
BOOL NSNextMapEnumeratorPair (NSMapEnumerator *enumerator,
void **key,
void **value);
NSArray *NSAllMapTableKeys (NSMapTable *table);
NSArray *NSAllMapTableValues (NSMapTable *table);
/** Adding an item to an NSMapTable **/
void NSMapInsert (NSMapTable *table, const void *key, const void *value);
void *NSMapInsertIfAbsent (NSMapTable *table,
const void *key,
const void *value);
void NSMapInsertKnownAbsent (NSMapTable *table,
const void *key,
const void *value);
/** Removing an item from an NSMapTable **/
void NSMapRemove (NSMapTable *table, const void *key);
/** Getting an NSString representation of an NSMapTable **/
NSString *NSStringFromMapTable (NSMapTable *table);
#endif /* __NSMapTable_h_OBJECTS_INCLUDE */

View file

@ -0,0 +1,41 @@
/* A hookable abort function for Libobjects.
* Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Sat Feb 10 12:34:27 EST 1996
* Updated: Sat Feb 10 15:49:43 EST 1996
* Serial: 96.02.10.03
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __abort_h_OBJECTS_INCLUDE
#define __abort_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
/**** Type, Constant, and Macro Definitions **********************************/
extern void (*__objects_abort) (void);
/**** Function Prototypes ****************************************************/
void objects_abort (void);
#endif /* __abort_h_OBJECTS_INCLUDE */

View file

@ -0,0 +1,82 @@
/* Modular memory management. Better living through chemicals.
* Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Thu Oct 13 23:46:02 EDT 1994
* Updated: Sat Feb 10 15:47:25 EST 1996
* Serial: 96.02.10.01
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __allocs_h_OBJECTS_INCLUDE
#define __allocs_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
#include <stdlib.h>
/**** Type, Constant, and Macro Definitions **********************************/
typedef void *(*objects_malloc_func_t) (size_t, void *);
typedef void *(*objects_calloc_func_t) (size_t, size_t, void *);
typedef void *(*objects_realloc_func_t) (void *, size_t, void *);
typedef void (*objects_free_func_t) (void *, void *);
typedef struct _objects_allocs objects_allocs_t;
struct _objects_allocs
{
objects_malloc_func_t malloc;
objects_calloc_func_t calloc;
objects_realloc_func_t realloc;
objects_free_func_t free;
void *user_data;
};
/* Shorthand macros. */
#define OBJECTS_MALLOC(S) objects_malloc(objects_standard_allocs(), (S))
#define OBJECTS_CALLOC(N, S) objects_calloc(objects_standard_allocs(), (N), (S))
#define OBJECTS_REALLOC(P, S) objects_realloc(objects_standard_allocs(), (P), (S))
#define OBJECTS_FREE(P) objects_free(objects_standard_allocs(), (P))
/* Change these if you need different default allocs. */
extern objects_allocs_t __objects_allocs_standard;
/**** Function Prototypes ****************************************************/
/* Returns `__objects_allocs_standard', defined above. */
objects_allocs_t
objects_allocs_standard (void);
void *
objects_malloc (objects_allocs_t allocs, size_t s);
void *
objects_calloc (objects_allocs_t allocs, size_t n, size_t s);
void *
objects_realloc (objects_allocs_t allocs, void *p, size_t s);
void
objects_free (objects_allocs_t allocs, void *p);
size_t
objects_next_power_of_two (size_t start);
#endif /* __allocs_h_OBJECTS_INCLUDE */

View file

@ -0,0 +1,198 @@
/* A sparse array for use with Libobjects.
* Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Thu Mar 2 02:30:02 EST 1994
* Updated: Sat Feb 10 15:38:58 EST 1996
* Serial: 96.02.10.01
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __array_h_OBJECTS_INCLUDE
#define __array_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
#include <stdlib.h>
#include <objects/allocs.h>
#include <objects/callbacks.h>
#include <objects/hash.h>
/**** Type, Constant, and Macro Definitions **********************************/
typedef struct _objects_array objects_array_t;
typedef struct _objects_array_bucket objects_array_bucket_t;
typedef objects_array_bucket_t *objects_array_slot_t;
typedef struct _objects_array_enumerator objects_array_enumerator_t;
struct _objects_array_bucket
{
/* The bucket's real (or external) index */
size_t index;
/* The bucket's cargo */
void *element;
};
struct _objects_array
{
/* Identifying information. */
int magic;
size_t number;
char *name;
void *extra;
objects_callbacks_t extra_callbacks;
objects_allocs_t allocs;
/* Callbacks for the items in the array. */
objects_callbacks_t callbacks;
/* Internal counters */
size_t slot_count;
size_t element_count;
/* Databanks */
objects_array_slot_t *slots;
objects_array_slot_t *sorted_slots;
};
struct _objects_array_enumerator
{
objects_array_t * array;
size_t index;
int is_sorted;
int is_ascending;
};
/**** Function Prototypes ****************************************************/
/** Basics **/
#include <objects/array-basics.h>
#include <objects/array-callbacks.h>
/** Creating **/
objects_array_t * objects_array_alloc (void);
objects_array_t * objects_array_alloc_with_allocs (objects_allocs_t allocs);
objects_array_t * objects_array (void);
objects_array_t * objects_array_with_allocs (objects_allocs_t allocs);
objects_array_t * objects_array_with_allocs_with_callbacks (objects_allocs_t allocs, objects_callbacks_t callbacks);
objects_array_t * objects_array_with_callbacks (objects_callbacks_t callbacks);
objects_array_t * objects_array_of_char_p (void);
objects_array_t * objects_array_of_void_p (void);
objects_array_t * objects_array_of_owned_void_p (void);
objects_array_t * objects_array_of_int (void);
objects_array_t * objects_array_of_id (void);
/** Initializing **/
objects_array_t * objects_array_init (objects_array_t * array);
objects_array_t * objects_array_init_with_callbacks (objects_array_t * array, objects_callbacks_t callbacks);
objects_array_t * objects_array_init_with_array (objects_array_t * array, objects_array_t * other_array);
/** Copying **/
objects_array_t * objects_array_copy (objects_array_t * array);
objects_array_t * objects_array_copy_with_allocs (objects_array_t * array, objects_allocs_t allocs);
/** Destroying **/
void objects_array_dealloc (objects_array_t * array);
/** Comparing **/
int objects_array_is_equal_to_array (objects_array_t * array, objects_array_t * other_array);
/** Adding **/
void *objects_array_at_index_put_element (objects_array_t * array, size_t index, void *element);
/** Replacing **/
/** Removing **/
void objects_array_remove_element_at_index (objects_array_t * array, size_t index);
void objects_array_remove_element (objects_array_t * array, void *element);
void objects_array_remove_element_known_present (objects_array_t * array, void *element);
/** Emptying **/
void objects_array_empty (objects_array_t * array);
/** Searching **/
int objects_array_contains_element (objects_array_t * array, void *element);
void *objects_array_element (objects_array_t * array, void *element);
size_t objects_array_index_of_element (objects_array_t * array, void *element);
void *objects_array_element_at_index (objects_array_t * array, size_t index);
void **objects_array_all_elements (objects_array_t * array);
void **objects_array_all_elements_ascending (objects_array_t * array);
void **objects_array_all_element_descending (objects_array_t * array);
/** Enumerating **/
objects_array_enumerator_t objects_array_enumerator (objects_array_t * array);
objects_array_enumerator_t objects_array_ascending_enumerator (objects_array_t * array);
objects_array_enumerator_t objects_array_descending_enumerator (objects_array_t * array);
int objects_array_enumerator_next_index_and_element (objects_array_enumerator_t *enumerator, size_t *index, void **element);
int objects_array_enumerator_next_element (objects_array_enumerator_t *enumerator, void **element);
int objects_array_enumerator_next_index (objects_array_enumerator_t *enumerator, size_t *element);
/** Statistics **/
int objects_array_is_empty (objects_array_t * array);
size_t objects_array_count (objects_array_t * array);
size_t objects_array_capacity (objects_array_t * array);
int objects_array_check (objects_array_t * array);
/** Miscellaneous **/
objects_hash_t *objects_hash_init_from_array (objects_hash_t *hash, objects_array_t *array);
#endif /* __array_h_OBJECTS_INCLUDE */

View file

@ -0,0 +1,52 @@
/* Handling the interface between allocs and zones.
* Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Sat Oct 15 10:40:40 EDT 1994
* Updated: Sat Feb 10 15:11:01 EST 1996
* Serial: 96.02.10.03
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
/**** Included Headers *******************************************************/
#include <objects/callbacks.h>
/**** Type, Constant, and Macro Definitions **********************************/
/**** Function Implementations ***********************************************/
#ifndef __???_h_OBJECTS_INCLUDE
#define __???_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
#include <Foundation/NSObject.h>
#include <Foundation/NSString.h>
#include <objects/allocs.h>
#include <objects/callbacks.h>
/**** Function Prototypes ****************************************************/
/** Translating from Zones to Allocs **/
objects_allocs_t
objects_allocs_for_zone (NSZone * zone);
#endif /* __???_h_OBJECTS_INCLUDE */

View file

@ -0,0 +1,59 @@
/* Macros for bit-wise operations.
* Copyright (C) 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Sat Feb 10 21:17:10 EST 1996
* Updated: Sat Feb 10 21:17:10 EST 1996
* Serial: 96.02.10.01
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
/**** Included Headers *******************************************************/
#include <objects/callbacks.h>
/**** Type, Constant, and Macro Definitions **********************************/
/**** Function Implementations ***********************************************/
#ifndef __bits_h_OBJECTS_INCLUDE
#define __bits_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
/**** Type, Constant, and Macro Definitions **********************************/
/** Bit operations **/
/* Set the Nth bit of V to one. */
#define OBJECTS_BIT_POKE(V,N) ((V) |= (1 << (N)))
/* Set the Nth bit of V to zero. */
#define OBJECTS_BIT_NOCK(V,N) ((V) &= ~(1 << (N)))
/* Toggle the Nth bit of V. */
#define OBJECTS_BIT_PLUK(V,N) ((V) ^= (1 << (N)))
/* Grab the Nth bit of V. */
#define OBJECTS_BIT_PEEK(V,N) ((V) & (1 << (N)))
/**** Function Prototypes ****************************************************/
#endif /* __bits_h_OBJECTS_INCLUDE */

241
Headers/gnustep/base/data.h Normal file
View file

@ -0,0 +1,241 @@
/* A modular data encapsulator for use with Libobjects.
* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Fri Nov 24 21:50:01 EST 1995
* Updated: Sat Feb 10 15:40:21 EST 1996
* Serial: 96.02.10.01
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __data_h_OBJECTS_INCLUDE
#define __data_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
#include <objects/allocs.h>
#include <objects/callbacks.h>
/**** Type, Constant, and Macro Definitions **********************************/
typedef enum _objects_data_encoding objects_data_encoding_t;
enum _objects_data_encoding
{
objects_data_encoding_unknown = -1,
objects_data_encoding_binary,
objects_data_encoding_7bit,
objects_data_encoding_8bit,
objects_data_encoding_base64,
objects_data_encoding_quoted_printable,
objects_data_encoding_x_uuencode
};
typedef struct _objects_data objects_data_t;
struct _objects_data
{
int magic;
size_t number;
char *name;
void *extra;
objects_callbacks_t extra_callbacks;
objects_allocs_t allocs;
/* Necessary information about the data. */
void *buffer; /* Where the stuff really is. */
size_t length; /* How much stuff there is. */
size_t capacity; /* How much room for stuff there is. */
};
/* Creating temporary data. This is *so* cool. GCC is awesome! */
#define OBJECTS_DATA(P, L) \
(objects_data_t *(&({OBJECTS_MAGIC_DATA, (size_t) -1, 0, \
0, 0, __objects_callbacks_standard, 0, 0, 0, \
__objects_allocs_standard, (P), (L), (L)})))
/**** Function Prototypes ****************************************************/
/** Basics **/
#include <objects/data-basics.h>
/** Hashing **/
size_t objects_data_hash (objects_data_t * data);
/** Creating **/
objects_data_t * objects_data_alloc (void);
objects_data_t * objects_data_alloc_with_allocs (objects_allocs_t allocs);
objects_data_t * objects_data_new (void);
objects_data_t * objects_data_new_with_allocs (objects_allocs_t allocs);
objects_data_t * _objects_data_with_allocs_with_contents_of_file (objects_allocs_t allocs, const char *file);
objects_data_t * _objects_data_with_contents_of_file (const char *file);
objects_data_t * objects_data_with_buffer_of_length (void *buffer, size_t length);
objects_data_t * objects_data_with_allocs_with_buffer_of_length (objects_allocs_t allocs, void *buffer, size_t length);
/** Initializing **/
objects_data_t * objects_data_init (objects_data_t * data);
objects_data_t * _objects_data_init_with_contents_of_file (objects_data_t * data, const char *file);
objects_data_t * objects_data_init_with_buffer_of_length (objects_data_t * data, void *buffer, size_t length);
/** Statistics **/
size_t objects_data_capacity (objects_data_t * data);
/* Obtain DATA's length. */
size_t objects_data_length (objects_data_t * data);
/* Obtain a read-only copy of DATA's buffer. */
const void *objects_data_buffer (objects_data_t * data);
/* Obtain DATA's capacity through reference. */
size_t objects_data_get_capacity (objects_data_t * data, size_t * capacity);
/* Obtain DATA's length through reference. */
size_t objects_data_get_length (objects_data_t * data, size_t * length);
/* Copy DATA's buffer into BUFFER. It is assumed that BUFFER is large
* enough to contain DATA's buffer. */
size_t objects_data_get_buffer (objects_data_t * data, void *buffer);
/* Copy no more that LENGTH of DATA's buffer into BUFFER. Returns the
* amount actually copied. */
size_t objects_data_get_buffer_of_length (objects_data_t * data, void *buffer, size_t length);
/* Copy a subrange of DATA's buffer into BUFFER. As always, it is
* assumed that BUFFER is large enough to contain everything. We
* return the size of the data actually copied into BUFFER. */
size_t objects_data_get_buffer_of_subrange (objects_data_t * data, void *buffer, size_t location, size_t length);
size_t objects_data_set_capacity (objects_data_t * data, size_t capacity);
size_t objects_data_increase_capacity (objects_data_t * data, size_t capacity);
size_t objects_data_decrease_capacity (objects_data_t * data, size_t capacity);
size_t objects_data_set_length (objects_data_t * data, size_t length);
size_t objects_data_set_buffer_of_subrange (objects_data_t * data, void *buffer, size_t location, size_t length);
size_t objects_data_set_buffer_of_length (objects_data_t * data, void *buffer, size_t length);
void objects_data_get_md5_checksum (objects_data_t * data, char *buffer);
/** Copying **/
objects_data_t * objects_data_copy (objects_data_t * data);
objects_data_t * objects_data_copy_of_subrange (objects_data_t * data, size_t location, size_t length);
objects_data_t * objects_data_copy_with_allocs (objects_data_t * data, objects_allocs_t allocs);
objects_data_t * objects_data_copy_of_subrange_with_allocs (objects_data_t * data, size_t location, size_t length, objects_allocs_t allocs);
/** Replacing **/
/* Note that we cannot do any bounds checking on BUFFER. */
objects_data_t * objects_data_replace_subrange_with_subrange_of_buffer (objects_data_t * data, size_t location, size_t length, size_t buf_location, size_t buf_length, void *buffer);
objects_data_t * objects_data_replace_subrange_with_subrange_of_data (objects_data_t * data, size_t location, size_t length, size_t other_location, size_t other_length, objects_data_t * other_data);
objects_data_t * objects_data_replace_subrange_with_data (objects_data_t * data, size_t location, size_t length, objects_data_t * other_data);
/** Appending **/
objects_data_t * objects_data_append_data (objects_data_t * data, objects_data_t * other_data);
objects_data_t * objects_data_append_subrange_of_data (objects_data_t * data, size_t location, size_t length, objects_data_t * other_data);
objects_data_t * objects_data_append_data_repeatedly (objects_data_t * data, objects_data_t * other_data, size_t num_times);
objects_data_t * objects_data_append_subrange_of_data_repeatedly (objects_data_t * data, size_t location, size_t length, objects_data_t * other_data, size_t num_times);
/** Prepending **/
objects_data_t * objects_data_prepend_data (objects_data_t * data, objects_data_t * other_data);
objects_data_t * objects_data_prepend_subrange_of_data (objects_data_t * data, size_t location, size_t length, objects_data_t * other_data);
objects_data_t * objects_data_prepend_data_repeatedly (objects_data_t * data, objects_data_t * other_data, size_t num_times);
objects_data_t * objects_data_prepend_subrange_of_data_repeatedly (objects_data_t * data, size_t location, size_t length, objects_data_t * other_data, size_t num_times);
/** Concatenating **/
objects_data_t * objects_data_concatenate_data (objects_data_t * data, objects_data_t * other_data);
objects_data_t * objects_data_concatenate_data_with_allocs (objects_data_t * data, objects_data_t * other_data, objects_allocs_t allocs);
objects_data_t * objects_data_concatenate_subrange_of_data (objects_data_t * data, size_t location, size_t length, objects_data_t * other_data);
objects_data_t * objects_data_concatenate_subrange_of_data_with_allocs (objects_data_t * data, size_t location, size_t length, objects_data_t * other_data, objects_allocs_t allocs);
/** Reversing **/
objects_data_t * objects_data_reverse_with_granularity (objects_data_t * data, size_t granularity);
objects_data_t * objects_data_reverse_by_int (objects_data_t * data);
objects_data_t * objects_data_reverse_by_char (objects_data_t * data);
objects_data_t * objects_data_reverse_by_void_p (objects_data_t * data);
/** Permuting **/
objects_data_t * objects_data_permute_with_granularity (objects_data_t * data, size_t granularity);
objects_data_t * objects_data_permute_with_no_fixed_points_with_granularity (objects_data_t * data, size_t granularity);
/** Writing **/
int _objects_data_write_to_file (objects_data_t * data, const char *file);
/** Encoding **/
objects_data_encoding_t objects_data_guess_data_encoding (objects_data_t * data);
objects_data_t * _objects_data_encode_with_base64 (objects_data_t * data);
objects_data_t * _objects_data_encode_with_quoted_printable (objects_data_t * data);
objects_data_t * _objects_data_encode_with_x_uuencode (objects_data_t * data);
objects_data_t * objects_data_encode_with_encoding (objects_data_t * data, objects_data_encoding_t enc);
objects_data_t * _objects_data_decode_with_base64 (objects_data_t * data);
objects_data_t * _objects_data_decode_with_quoted_printable (objects_data_t * data);
objects_data_t * _objects_data_decode_with_x_uuencode (objects_data_t * data);
objects_data_t * objects_data_decode_with_encoding (objects_data_t * data, objects_data_encoding_t enc);
#endif /* __data_h_OBJECTS_INCLUDE */

220
Headers/gnustep/base/hash.h Normal file
View file

@ -0,0 +1,220 @@
/* A hash table for use with Libobjects.
* Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: ??? ??? ?? ??:??:?? ??? 1993
* Updated: Sat Feb 10 15:35:37 EST 1996
* Serial: 96.02.10.01
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __hash_h_OBJECTS_INCLUDE
#define __hash_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
#include <objects/allocs.h>
#include <objects/callbacks.h>
/**** Type, Constant, and Macro Definitions **********************************/
typedef struct _objects_hash objects_hash_t;
typedef struct _objects_hash_bucket objects_hash_bucket_t;
typedef struct _objects_hash_node objects_hash_node_t;
typedef struct _objects_hash_enumerator objects_hash_enumerator_t;
struct _objects_hash_node
{
objects_hash_t *hash;
objects_hash_bucket_t *bucket;
objects_hash_node_t *next_in_bucket;
objects_hash_node_t *prev_in_bucket;
objects_hash_node_t *next_in_hash;
objects_hash_node_t *prev_in_hash;
void *element;
};
struct _objects_hash_bucket
{
size_t node_count;
size_t element_count;
objects_hash_node_t *first_node;
};
struct _objects_hash
{
int magic;
size_t number;
char *name;
void *extra;
objects_callbacks_t extra_callbacks;
objects_allocs_t allocs;
/* Callbacks for the items in the hash. */
objects_callbacks_t callbacks;
/* Internal hash counters. */
size_t bucket_count; /* How many types of items? */
size_t node_count; /* How many items? */
size_t element_count; /* How many elements? */
/* Places to start looking for elements. */
objects_hash_bucket_t *buckets;
objects_hash_node_t *first_node;
};
struct _objects_hash_enumerator
{
objects_hash_t *hash;
objects_hash_node_t *node;
};
/**** Function Prototypes ****************************************************/
/** Basics **/
#include <objects/hash-basics.h>
#include <objects/hash-callbacks.h>
/** Hashing **/
size_t objects_hash_hash (objects_hash_t * hash);
/** Creating **/
objects_hash_t * objects_hash_alloc (void);
objects_hash_t * objects_hash_alloc_with_allocs (objects_allocs_t alloc);
objects_hash_t * objects_hash_with_callbacks (objects_callbacks_t callbacks);
objects_hash_t * objects_hash_with_allocs (objects_allocs_t allocs);
objects_hash_t * objects_hash_with_allocs_with_callbacks (objects_allocs_t allocs, objects_callbacks_t callbacks);
objects_hash_t * objects_hash_of_char_p (void);
objects_hash_t * objects_hash_of_void_p (void);
objects_hash_t * objects_hash_of_owned_void_p (void);
objects_hash_t * objects_hash_of_int (void);
objects_hash_t * objects_hash_of_id (void);
/** Initializing **/
objects_hash_t * objects_hash_init (objects_hash_t * hash);
objects_hash_t * objects_hash_init_with_callbacks (objects_hash_t * hash, objects_callbacks_t callbacks);
objects_hash_t * objects_hash_init_with_hash (objects_hash_t * hash, objects_hash_t * other_hash);
/** Copying **/
objects_hash_t * objects_hash_copy (objects_hash_t * old_hash);
objects_hash_t * objects_hash_copy_with_allocs (objects_hash_t * hash, objects_allocs_t new_allocs);
/** Mapping **/
/* WARNING: The mapping function FCN must be one-to-one on elements of
* HASH. I.e., for reasons of efficiency, `objects_hash_map_elements()'
* makes no provision for the possibility that FCN maps two unequal
* elements of HASH to the same (or equal) elements. The better way
* to handle functions that aren't one-to-one is to create a new hash
* and transform the elements of the first to create the elements of
* the second. */
objects_hash_t * objects_hash_map_elements (objects_hash_t * hash, void *(*fcn) (void *, void *), void *user_data);
/** Destroying **/
void objects_hash_dealloc (objects_hash_t * hash);
/** Comparing **/
int objects_hash_contains_hash (objects_hash_t * hash, objects_hash_t * other_hash);
int objects_hash_intersects_hash (objects_hash_t * hash, objects_hash_t * other_hash);
int objects_hash_is_equal_to_hash (objects_hash_t * hash, objects_hash_t * other_hash);
/** Adding **/
void *objects_hash_add_element_known_absent (objects_hash_t * hash, void *element);
void *objects_hash_add_element (objects_hash_t * hash, void *element);
void *objects_hash_add_element_if_absent (objects_hash_t * hash, void *element);
/** Replacing **/
void objects_hash_replace_element (objects_hash_t * hash, void *element);
/** Removing **/
void objects_hash_remove_element (objects_hash_t * hash, void *element);
/** Emptying **/
void objects_hash_empty (objects_hash_t * hash);
/** Searching **/
void *objects_hash_any_element (objects_hash_t * hash);
int objects_hash_contains_element (objects_hash_t * hash, void *element);
void *objects_hash_element (objects_hash_t * hash, void *element);
void **objects_hash_all_elements (objects_hash_t * hash);
/** Enumerating **/
objects_hash_enumerator_t objects_hash_enumerator (objects_hash_t * hash);
int objects_hash_enumerator_next_element (objects_hash_enumerator_t *enumerator, void **element);
/** Statistics **/
int objects_hash_is_empty (objects_hash_t * hash);
size_t objects_hash_count (objects_hash_t * hash);
size_t objects_hash_capacity (objects_hash_t * hash);
int objects_hash_check (objects_hash_t * hash);
/** Miscellaneous **/
size_t objects_hash_resize (objects_hash_t * hash, size_t new_capacity);
size_t objects_hash_rightsize (objects_hash_t * hash);
objects_hash_t * objects_hash_intersect_hash (objects_hash_t * hash, objects_hash_t * other_hash);
objects_hash_t * objects_hash_minus_hash (objects_hash_t * hash, objects_hash_t * other_hash);
objects_hash_t * objects_hash_union_hash (objects_hash_t * hash, objects_hash_t * other_hash);
#endif /* __hash_h_OBJECTS_INCLUDE */

252
Headers/gnustep/base/list.h Normal file
View file

@ -0,0 +1,252 @@
/* A list for use with Libobjects.
* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Tue Sep 5 17:25:59 EDT 1995
* Updated: Sat Feb 10 15:37:41 EST 1996
* Serial: 96.02.10.01
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __list_h_OBJECTS_INCLUDE
#define __list_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
#include <objects/allocs.h>
#include <objects/callbacks.h>
#include <objects/hash.h>
#include <objects/array.h>
/**** Type, Constant, and Macro Definitions **********************************/
typedef struct _objects_list objects_list_t;
typedef struct _objects_list_node objects_list_node_t;
typedef struct _objects_list_enumerator objects_list_enumerator_t;
struct _objects_list_node
{
objects_list_t * list;
objects_list_node_t *next_in_list;
objects_list_node_t *prev_in_list;
void *element;
};
struct _objects_list
{
/* Container identifiers */
int magic;
size_t number;
char *name;
void *extra;
objects_callbacks_t extra_callbacks;
objects_allocs_t allocs;
/* Element callbacks */
objects_callbacks_t callbacks;
/* Internal counters */
size_t node_count;
size_t element_count;
/* Databanks */
objects_list_node_t *first_node;
objects_list_node_t *last_node;
};
struct _objects_list_enumerator
{
objects_list_t *list;
objects_list_node_t *node;
size_t forward;
};
/**** Function Prototypes ****************************************************/
/** Basics **/
#include <objects/list-basics.h>
#include <objects/list-callbacks.h>
/** Creating **/
objects_list_t * objects_list_alloc (void);
objects_list_t * objects_list_alloc_with_allocs (objects_allocs_t allocs);
objects_list_t * objects_list_with_allocs (objects_allocs_t allocs);
objects_list_t * objects_list_with_callbacks (objects_callbacks_t callbacks);
objects_list_t * objects_list_with_allocs_with_callbacks (objects_allocs_t allocs, objects_callbacks_t callbacks);
objects_list_t * objects_list_of_char_p (void);
objects_list_t * objects_list_of_void_p (void);
objects_list_t * objects_list_of_owned_void_p (void);
objects_list_t * objects_list_of_int (void);
objects_list_t * objects_list_of_int_p (void);
objects_list_t * objects_list_of_id (void);
/** Initializing **/
objects_list_t * objects_list_init (objects_list_t * list);
objects_list_t * objects_list_init_with_callbacks (objects_list_t * list, objects_callbacks_t callbacks);
/** Copying **/
objects_list_t * objects_list_copy (objects_list_t * old_list);
objects_list_t * objects_list_copy_with_allocs (objects_list_t * old_list, objects_allocs_t allocs);
/** Destroying **/
void objects_list_dealloc (objects_list_t * list);
/** Comparing **/
int objects_list_is_equal_to_list (objects_list_t * list, objects_list_t * other_list);
/** Concatenating **/
objects_list_t * objects_list_append_list (objects_list_t * base_list, objects_list_t * suffix_list);
objects_list_t * objects_list_prepend_list (objects_list_t * base_list, objects_list_t * prefix_list);
objects_list_t * objects_list_at_index_insert_list (objects_list_t * base_list, long int n, objects_list_t * infix_list);
/** Permuting **/
objects_list_t * objects_list_roll_to_nth_element (objects_list_t * list, long int n);
objects_list_t * objects_list_roll_to_element (objects_list_t * list, void *element);
objects_list_t * objects_list_roll_to_nth_occurrance_of_element (objects_list_t * list, long int n, void *element);
objects_list_t * objects_list_invert (objects_list_t * list);
objects_list_t * objects_list_swap_elements_at_indices (objects_list_t * list, long int m, long int n);
/** Adding **/
void *objects_list_append_element (objects_list_t * list, void *element);
void *objects_list_append_element_if_absent (objects_list_t * list, void *element);
void *objects_list_prepend_element (objects_list_t * list, void *element);
void *objects_list_prepend_element_if_absent (objects_list_t * list, void *element);
void *objects_list_at_index_insert_element (objects_list_t * list, long int n, void *element);
void *objects_list_at_index_insert_element_if_absent (objects_list_t * list, long int n, void *element);
void *objects_list_queue_push_element (objects_list_t * list, void *element);
void *objects_list_stack_push_element (objects_list_t * list, void *element);
/** Replacing **/
void objects_list_replace_nth_occurrance_of_element (objects_list_t * list, long int n, void *old_element, void *new_element);
void objects_list_replace_element (objects_list_t * list, void *old_element, void *new_element);
void objects_list_replace_nth_element (objects_list_t * list, long int n, void *new_element);
void objects_list_replace_first_element (objects_list_t * list, void *new_element);
void objects_list_replace_last_element (objects_list_t * list, void *new_element);
/** Removing **/
void objects_list_remove_nth_occurrence_of_element (objects_list_t * list, long int n, void *element);
void objects_list_remove_element (objects_list_t * list, void *element);
void objects_list_remove_nth_element (objects_list_t * list, long int n);
void objects_list_remove_first_element (objects_list_t * list);
void objects_list_remove_last_element (objects_list_t * list);
void objects_list_queue_pop_element (objects_list_t * list);
void objects_list_queue_pop_nth_element (objects_list_t * list, long int n);
void objects_list_stack_pop_element (objects_list_t * list);
void objects_list_stack_pop_nth_element (objects_list_t * list, long int n);
/** Emptying **/
void objects_list_empty (objects_list_t * list);
/** Searching **/
int objects_list_contains_element (objects_list_t * list, void *element);
void *objects_list_element (objects_list_t * list, void *element);
void *objects_list_nth_element (objects_list_t * list, long int n);
void *objects_list_first_element (objects_list_t * list);
void *objects_list_last_element (objects_list_t * list);
void **objects_list_all_elements (objects_list_t * list);
/** Enumerating **/
objects_list_enumerator_t objects_list_enumerator (objects_list_t * list);
objects_list_enumerator_t objects_list_forward_enumerator (objects_list_t * list);
objects_list_enumerator_t objects_list_reverse_enumerator (objects_list_t * list);
int objects_list_enumerator_next_element (objects_list_enumerator_t *enumerator, void **element);
/** Mapping **/
/* NO WARNING: The mapping function FCN need not be one-to-one on the
* elements of LIST. In fact, FCN may do whatever it likes. */
objects_list_t * objects_list_map_elements (objects_list_t * list, void *(*fcn) (void *, void *), void *user_data);
/** Statistics **/
int objects_list_is_empty (objects_list_t * list);
size_t objects_list_count (objects_list_t * list);
size_t objects_list_capacity (objects_list_t * list);
int objects_list_check (objects_list_t * list);
/** Miscellaneous **/
objects_hash_t *objects_hash_init_from_list (objects_hash_t *hash, objects_list_t * list);
#endif /* __list_h_OBJECTS_INCLUDE */

View file

@ -0,0 +1,56 @@
/* Magic numbers for identifying Libobjects structures.
* Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Thu Mar 2 02:10:10 EST 1994
* Updated: Sat Feb 10 15:42:11 EST 1996
* Serial: 96.02.10.01
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __magic_h_OBJECTS_INCLUDE
#define __magic_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
/**** Type, Constant, and Macro Definitions **********************************/
/** Magic numbers **/
#define OBJECTS_MAGIC_ARRAY 0xfa138008 /* Thu Mar 2 02:28:50 EST 1994 */
#define OBJECTS_MAGIC_DATA 0xfa131971 /* Fri Nov 24 21:46:14 EST 1995 */
#define OBJECTS_MAGIC_HASH 0xfa133ee5 /* ??? ??? ?? ??:??:?? ??? 1993 */
#define OBJECTS_MAGIC_HEAP 0xfa13beef /* Tue Sep 5 17:21:34 EDT 1995 */
#define OBJECTS_MAGIC_LIST 0xfa13600d /* Tue Sep 5 17:23:50 EDT 1995 */
#define OBJECTS_MAGIC_MAP 0xfa13abba /* ??? ??? ?? ??:??:?? ??? 1993 */
/* WARNING: Don't use these. They are not guaranteed to remain in future
* editions of this file. They are here only as a cheap fix for an
* annoying little problem. */
/* FIXME: Get rid of these. See `x-basics.[ch].in'
* and `x-callbacks.[ch].in'. */
#define _OBJECTS_MAGIC_array OBJECTS_MAGIC_ARRAY
#define _OBJECTS_MAGIC_data OBJECTS_MAGIC_DATA
#define _OBJECTS_MAGIC_hash OBJECTS_MAGIC_HASH
#define _OBJECTS_MAGIC_heap OBJECTS_MAGIC_HEAP
#define _OBJECTS_MAGIC_list OBJECTS_MAGIC_LIST
#define _OBJECTS_MAGIC_map OBJECTS_MAGIC_MAP
#endif /* __magic_h_OBJECTS_INCLUDE */

330
Headers/gnustep/base/map.h Normal file
View file

@ -0,0 +1,330 @@
/* A map table for use with Libobjects.
* Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: ??? ??? ?? ??:??:?? ??? 1993
* Updated: Sat Feb 10 13:36:59 EST 1996
* Serial: 96.02.10.01
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __map_h_OBJECTS_INCLUDE
#define __map_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
#include <objects/allocs.h>
#include <objects/callbacks.h>
#include <objects/hash.h>
/**** Type, Constant, and Macro Definitions **********************************/
typedef struct _objects_map objects_map_t;
typedef struct _objects_map_bucket objects_map_bucket_t;
typedef struct _objects_map_node objects_map_node_t;
typedef struct _objects_map_enumerator objects_map_enumerator_t;
/* Important structures... */
struct _objects_map_node
{
void *key;
void *value;
objects_map_bucket_t *bucket;
objects_map_t *map;
objects_map_node_t *next_in_bucket;
objects_map_node_t *prev_in_bucket;
objects_map_node_t *next_in_map;
objects_map_node_t *prev_in_map;
};
struct _objects_map_bucket
{
size_t node_count;
size_t element_count;
objects_map_node_t *first_node;
};
struct _objects_map
{
/* Container identifiers */
int magic;
size_t number;
char *name;
void *extra;
objects_callbacks_t extra_callbacks;
objects_allocs_t allocs;
objects_callbacks_t key_callbacks;
/* Management information */
objects_callbacks_t value_callbacks;
/* Internal counters */
size_t bucket_count;
size_t node_count;
size_t element_count;
/* Databanks */
objects_map_bucket_t *buckets;
objects_map_node_t *first_node;
};
struct _objects_map_enumerator
{
objects_map_t *map;
objects_map_node_t *node;
};
/**** Function Prototypes ****************************************************/
/** Basics **/
#include <objects/map-basics.h>
#include <objects/map-callbacks.h>
/** Altering capacity **/
size_t
objects_map_resize (objects_map_t * map, size_t new_capacity);
size_t
objects_map_rightsize (objects_map_t * map);
/** Creating **/
objects_map_t *
objects_map_alloc (void);
objects_map_t *
objects_map_alloc_with_allocs (objects_allocs_t allocs);
objects_map_t *
objects_map (void);
objects_map_t *
objects_map_with_allocs (objects_allocs_t allocs);
objects_map_t *
objects_map_with_allocs_with_callbacks (objects_allocs_t allocs,
objects_callbacks_t key_callbacks,
objects_callbacks_t value_callbacks);
objects_map_t *
objects_map_with_callbacks (objects_callbacks_t key_callbacks,
objects_callbacks_t value_callbacks);
objects_map_t *
objects_map_of_int (void);
objects_map_t *
objects_map_of_int_to_char_p (void);
objects_map_t *
objects_map_of_int_to_void_p (void);
objects_map_t *
objects_map_of_int_to_float (void);
objects_map_t *
objects_map_of_char_p (void);
objects_map_t *
objects_map_of_char_p_to_int (void);
objects_map_t *
objects_map_of_char_p_to_void_p (void);
objects_map_t *
objects_map_of_char_p_to_float (void);
objects_map_t *
objects_map_of_void_p (void);
objects_map_t *
objects_map_of_void_p_to_int (void);
objects_map_t *
objects_map_of_void_p_to_char_p (void);
objects_map_t *
objects_map_of_void_p_to_float (void);
objects_map_t *
objects_map_of_float (void);
objects_map_t *
objects_map_of_double (void);
/** Initializing **/
objects_map_t *
objects_map_init (objects_map_t * map);
objects_map_t *
objects_map_init_with_callbacks (objects_map_t * map,
objects_callbacks_t key_callbacks,
objects_callbacks_t value_callbacks);
/** Destroying **/
void
objects_map_dealloc (objects_map_t * map);
/** Gathering statistics on a mapionary **/
size_t
objects_map_pair_count (objects_map_t * map);
size_t
objects_map_capacity (objects_map_t * map);
int
objects_map_check_map (objects_map_t * map);
/** Finding elements in a mapionary **/
int
objects_map_contains_key (objects_map_t * map, void *key);
int
objects_map_key_and_value (objects_map_t * map,
void *key,
void **old_key,
void **value);
void *
objects_map_key (objects_map_t * map, void *key);
void *
objects_map_value (objects_map_t * map, void *key);
/** Enumerating the nodes and elements of a mapionary **/
objects_map_enumerator_t
objects_map_enumerator (objects_map_t * map);
int
objects_map_enumerator_next_key_and_value (objects_map_enumerator_t * enumerator,
void **key,
void **value);
int
objects_map_enumerator_next_key (objects_map_enumerator_t * enumerator,
void **key);
int
objects_map_enumerator_next_value (objects_map_enumerator_t * enumerator,
void **value);
/** Obtaining an array of the elements of a mapionary **/
void **
objects_map_all_keys_and_values (objects_map_t * map);
void **
objects_map_all_keys (objects_map_t * map);
void **
objects_map_all_values (objects_map_t * map);
/** Removing **/
void
objects_map_remove_key (objects_map_t * map, void *key);
void
objects_map_empty (objects_map_t * map);
/** Adding **/
void *
objects_map_at_key_put_value_known_absent (objects_map_t * map,
void *key,
void *value);
void *
objects_map_at_key_put_value (objects_map_t * map,
void *key,
void *value);
void *
objects_map_at_key_put_value_if_absent (objects_map_t * map,
void *key,
void *value);
/** Replacing **/
void
objects_map_replace_key (objects_map_t * map, void *key);
/** Comparing **/
int
objects_map_contains_map (objects_map_t * map1, objects_map_t * map2);
int
objects_map_is_equal_to_map (objects_map_t * map1, objects_map_t * map2);
/** Copying **/
objects_map_t *
objects_map_copy_with_allocs (objects_map_t * old_map, objects_allocs_t new_allocs);
objects_map_t *
objects_map_copy (objects_map_t * old_map);
/** Mapping **/
/* WARNING: The mapping function KFCN must be one-to-one on the keys
* of MAP. I.e., `objects_map_map_keys()' makes no provision for the
* possibility that KFCN maps two unequal keys of MAP to the same (or
* equal) keys. */
objects_map_t *
objects_map_map_keys (objects_map_t * map,
void *(*kfcn) (void *, void *),
void *user_data);
/* NO WARNING: The mapping function VFCN need not be one-to-one on
* (the equivalence classes of) values. */
objects_map_t *
objects_map_map_values (objects_map_t * map,
void *(*vfcn) (void *, void *),
void *user_data);
/** Miscellaneous **/
objects_map_t *
objects_map_intersect_map (objects_map_t * map, objects_map_t * other_map);
objects_map_t *
objects_map_minus_map (objects_map_t * map, objects_map_t * other_map);
objects_map_t *
objects_map_union_map (objects_map_t * map, objects_map_t * other_map);
objects_hash_t *
objects_hash_init_from_map_keys (objects_hash_t * hash, objects_map_t * map);
objects_hash_t *
objects_hash_init_from_map_values (objects_hash_t * hash, objects_map_t * map);
#endif /* __map_h_OBJECTS_INCLUDE */

View file

@ -0,0 +1,51 @@
/* GCC macros for minimum and maximum.
* Copyright (C) 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Sat Feb 10 21:13:04 EST 1996
* Updated: Sat Feb 10 21:13:04 EST 1996
* Serial: 96.02.10.01
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __minmax_h_OBJECTS_INCLUDE
#define __minmax_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
/**** Type, Constant, and Macro Definitions **********************************/
#ifdef MIN
#undef MIN
#endif /* !MIN */
#define MIN(X, Y) \
({ typeof (X) __x = (X), __y = (Y); \
(__x < __y) ? __x : __y; })
#ifdef MAX
#undef MAX
#endif /* !MAX */
#define MAX(X, Y) \
({ typeof (X) __x = (X), __y = (Y); \
(__x > __y) ? __x : __y; })
#endif /* __minmax_h_OBJECTS_INCLUDE */

View file

@ -0,0 +1,49 @@
/* Structure counters and functions for getting at them.
* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Sun Dec 3 00:28:01 EST 1995
* Updated: Sat Feb 10 15:51:02 EST 1996
* Serial: 96.02.10.01
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __number_h_OBJECTS_INCLUDE
#define __number_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
#include <stdlib.h>
/**** Type, Constant, and Macro Definitions **********************************/
extern size_t ___objects_number_allocated;
extern size_t ___objects_number_deallocated;
extern size_t ___objects_number_serial;
/**** Function Prototypes ****************************************************/
size_t _objects_number_allocated(void);
size_t _objects_number_deallocated(void);
size_t _objects_number_serial(void);
#endif /* __number_h_OBJECTS_INCLUDE */

View file

@ -0,0 +1,198 @@
/* A sparse array for use with Libobjects.
* Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Thu Mar 2 02:30:02 EST 1994
* Updated: Sat Feb 10 15:38:58 EST 1996
* Serial: 96.02.10.01
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __array_h_OBJECTS_INCLUDE
#define __array_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
#include <stdlib.h>
#include <objects/allocs.h>
#include <objects/callbacks.h>
#include <objects/hash.h>
/**** Type, Constant, and Macro Definitions **********************************/
typedef struct _objects_array objects_array_t;
typedef struct _objects_array_bucket objects_array_bucket_t;
typedef objects_array_bucket_t *objects_array_slot_t;
typedef struct _objects_array_enumerator objects_array_enumerator_t;
struct _objects_array_bucket
{
/* The bucket's real (or external) index */
size_t index;
/* The bucket's cargo */
void *element;
};
struct _objects_array
{
/* Identifying information. */
int magic;
size_t number;
char *name;
void *extra;
objects_callbacks_t extra_callbacks;
objects_allocs_t allocs;
/* Callbacks for the items in the array. */
objects_callbacks_t callbacks;
/* Internal counters */
size_t slot_count;
size_t element_count;
/* Databanks */
objects_array_slot_t *slots;
objects_array_slot_t *sorted_slots;
};
struct _objects_array_enumerator
{
objects_array_t * array;
size_t index;
int is_sorted;
int is_ascending;
};
/**** Function Prototypes ****************************************************/
/** Basics **/
#include <objects/array-basics.h>
#include <objects/array-callbacks.h>
/** Creating **/
objects_array_t * objects_array_alloc (void);
objects_array_t * objects_array_alloc_with_allocs (objects_allocs_t allocs);
objects_array_t * objects_array (void);
objects_array_t * objects_array_with_allocs (objects_allocs_t allocs);
objects_array_t * objects_array_with_allocs_with_callbacks (objects_allocs_t allocs, objects_callbacks_t callbacks);
objects_array_t * objects_array_with_callbacks (objects_callbacks_t callbacks);
objects_array_t * objects_array_of_char_p (void);
objects_array_t * objects_array_of_void_p (void);
objects_array_t * objects_array_of_owned_void_p (void);
objects_array_t * objects_array_of_int (void);
objects_array_t * objects_array_of_id (void);
/** Initializing **/
objects_array_t * objects_array_init (objects_array_t * array);
objects_array_t * objects_array_init_with_callbacks (objects_array_t * array, objects_callbacks_t callbacks);
objects_array_t * objects_array_init_with_array (objects_array_t * array, objects_array_t * other_array);
/** Copying **/
objects_array_t * objects_array_copy (objects_array_t * array);
objects_array_t * objects_array_copy_with_allocs (objects_array_t * array, objects_allocs_t allocs);
/** Destroying **/
void objects_array_dealloc (objects_array_t * array);
/** Comparing **/
int objects_array_is_equal_to_array (objects_array_t * array, objects_array_t * other_array);
/** Adding **/
void *objects_array_at_index_put_element (objects_array_t * array, size_t index, void *element);
/** Replacing **/
/** Removing **/
void objects_array_remove_element_at_index (objects_array_t * array, size_t index);
void objects_array_remove_element (objects_array_t * array, void *element);
void objects_array_remove_element_known_present (objects_array_t * array, void *element);
/** Emptying **/
void objects_array_empty (objects_array_t * array);
/** Searching **/
int objects_array_contains_element (objects_array_t * array, void *element);
void *objects_array_element (objects_array_t * array, void *element);
size_t objects_array_index_of_element (objects_array_t * array, void *element);
void *objects_array_element_at_index (objects_array_t * array, size_t index);
void **objects_array_all_elements (objects_array_t * array);
void **objects_array_all_elements_ascending (objects_array_t * array);
void **objects_array_all_element_descending (objects_array_t * array);
/** Enumerating **/
objects_array_enumerator_t objects_array_enumerator (objects_array_t * array);
objects_array_enumerator_t objects_array_ascending_enumerator (objects_array_t * array);
objects_array_enumerator_t objects_array_descending_enumerator (objects_array_t * array);
int objects_array_enumerator_next_index_and_element (objects_array_enumerator_t *enumerator, size_t *index, void **element);
int objects_array_enumerator_next_element (objects_array_enumerator_t *enumerator, void **element);
int objects_array_enumerator_next_index (objects_array_enumerator_t *enumerator, size_t *element);
/** Statistics **/
int objects_array_is_empty (objects_array_t * array);
size_t objects_array_count (objects_array_t * array);
size_t objects_array_capacity (objects_array_t * array);
int objects_array_check (objects_array_t * array);
/** Miscellaneous **/
objects_hash_t *objects_hash_init_from_array (objects_hash_t *hash, objects_array_t *array);
#endif /* __array_h_OBJECTS_INCLUDE */

View file

@ -0,0 +1,172 @@
/* Handling various types in a uniform manner.
* Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Sun Oct 9 13:18:50 EDT 1994
* Updated: Sun Feb 11 01:46:03 EST 1996
* Serial: 96.02.11.01
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __callbacks_h_OBJECTS_INCLUDE
#define __callbacks_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
#include <stdlib.h>
/**** Type, Constant, and Macro Definitions **********************************/
typedef size_t (*objects_hash_func_t) (void *, void *);
typedef int (*objects_compare_func_t) (void *, void *, void *);
typedef int (*objects_is_equal_func_t) (void *, void *, void *);
typedef void *(*objects_retain_func_t) (void *, void *);
typedef void (*objects_release_func_t) (void *, void *);
typedef void *(*objects_describe_func_t) (void *, void *);
typedef struct _objects_callbacks objects_callbacks_t;
struct _objects_callbacks
{
objects_hash_func_t hash;
objects_compare_func_t compare;
objects_is_equal_func_t is_equal;
objects_retain_func_t retain;
objects_release_func_t release;
objects_describe_func_t describe;
void *not_an_item_marker;
};
/** Callbacks for various types **/
extern const objects_callbacks_t objects_callbacks_for_int;
extern const objects_callbacks_t objects_callbacks_for_char_p;
extern const objects_callbacks_t objects_callbacks_for_void_p;
extern const objects_callbacks_t objects_callbacks_for_owned_void_p;
extern const objects_callbacks_t objects_callbacks_for_int_p;
extern const objects_callbacks_t objects_callbacks_for_id;
/* FIXME: I need to figure out what each of these should be. Hmmm? */
extern const void *objects_not_an_int_marker;
extern const void *objects_not_a_char_p_marker;
extern const void *objects_not_a_void_p_marker;
extern const void *objects_not_an_int_p_marker;
extern const void *objects_not_an_id_marker;
/* Change this if you need different default callbacks. */
extern objects_callbacks_t __objects_callbacks_standard;
/**** Function Prototypes ****************************************************/
/** Generic callbacks **/
/* Returns `__objects_callbacks_standard', defined above. */
objects_callbacks_t
objects_callbacks_standard (void);
/** Standardizing callbacks **/
objects_callbacks_t
objects_callbacks_standardize (objects_callbacks_t callbacks);
/** Using callbacks **/
size_t objects_hash (objects_callbacks_t callbacks,
void *thing,
void *user_data);
int objects_compare (objects_callbacks_t callbacks,
void *thing1,
void *thing2,
void *user_data);
int objects_is_equal (objects_callbacks_t callbacks,
void *thing1,
void *thing2,
void *user_data);
void *objects_retain (objects_callbacks_t callbacks,
void *thing,
void *user_data);
void objects_release (objects_callbacks_t callbacks,
void *thing,
void *user_data);
/* FIXME: Decide what to do with this describe stuff. We'd really like
* them to return Strings? Or would we rather they be `char *'s?
* Or something else? */
void *objects_describe (objects_callbacks_t callbacks,
void *thing,
void *user_data);
void *objects_not_an_item_marker (objects_callbacks_t);
/** Specific callback functions **/
/* For `void *' */
size_t objects_void_p_hash(void *ptr);
int objects_void_p_compare(void *ptr, void *qtr);
int objects_void_p_is_equal(void *ptr, void *qtr);
void *objects_void_p_retain(void *ptr);
void objects_void_p_release(void *ptr);
void *objects_void_p_describe(void *ptr);
/* For `void *' */
size_t objects_owned_void_p_hash(void *ptr);
int objects_owned_void_p_compare(void *ptr, void *qtr);
int objects_owned_void_p_is_equal(void *ptr, void *qtr);
void *objects_owned_void_p_retain(void *ptr);
void objects_owned_void_p_release(void *ptr);
void *objects_owned_void_p_describe(void *ptr);
/* For `int' */
size_t objects_int_hash(void *i);
int objects_int_compare(void *i, void *j);
int objects_int_is_equal(void *i, void *j);
void *objects_int_retain(void *i);
void objects_int_release(void *i);
void *objects_int_describe(void *i);
/* For `int *' */
size_t objects_int_p_hash(void *iptr);
int objects_int_p_compare(void *iptr, void *jptr);
int objects_int_p_is_equal(void *iptr, void *jptr);
void *objects_int_p_retain(void *iptr);
void objects_int_p_release(void *iptr);
void *objects_int_p_describe(void *iptr);
/* For `char *' */
size_t objects_char_p_hash(void *cptr);
int objects_char_p_compare(void *cptr, void *dptr);
int objects_char_p_is_equal(void *cptr, void *dptr);
void *objects_char_p_retain(void *cptr);
void objects_char_p_release(void *cptr);
void *objects_char_p_describe(void *cptr);
/* For `id' */
size_t objects_id_hash(void *obj);
int objects_id_compare(void *obj, void *jbo);
int objects_id_is_equal(void *obj, void *jbo);
void *objects_id_retain(void *obj);
void objects_id_release(void *obj);
void *objects_id_describe(void *obj);
#endif /* __callbacks_h_OBJECTS_INCLUDE */

View file

@ -0,0 +1,220 @@
/* A hash table for use with Libobjects.
* Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: ??? ??? ?? ??:??:?? ??? 1993
* Updated: Sat Feb 10 15:35:37 EST 1996
* Serial: 96.02.10.01
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __hash_h_OBJECTS_INCLUDE
#define __hash_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
#include <objects/allocs.h>
#include <objects/callbacks.h>
/**** Type, Constant, and Macro Definitions **********************************/
typedef struct _objects_hash objects_hash_t;
typedef struct _objects_hash_bucket objects_hash_bucket_t;
typedef struct _objects_hash_node objects_hash_node_t;
typedef struct _objects_hash_enumerator objects_hash_enumerator_t;
struct _objects_hash_node
{
objects_hash_t *hash;
objects_hash_bucket_t *bucket;
objects_hash_node_t *next_in_bucket;
objects_hash_node_t *prev_in_bucket;
objects_hash_node_t *next_in_hash;
objects_hash_node_t *prev_in_hash;
void *element;
};
struct _objects_hash_bucket
{
size_t node_count;
size_t element_count;
objects_hash_node_t *first_node;
};
struct _objects_hash
{
int magic;
size_t number;
char *name;
void *extra;
objects_callbacks_t extra_callbacks;
objects_allocs_t allocs;
/* Callbacks for the items in the hash. */
objects_callbacks_t callbacks;
/* Internal hash counters. */
size_t bucket_count; /* How many types of items? */
size_t node_count; /* How many items? */
size_t element_count; /* How many elements? */
/* Places to start looking for elements. */
objects_hash_bucket_t *buckets;
objects_hash_node_t *first_node;
};
struct _objects_hash_enumerator
{
objects_hash_t *hash;
objects_hash_node_t *node;
};
/**** Function Prototypes ****************************************************/
/** Basics **/
#include <objects/hash-basics.h>
#include <objects/hash-callbacks.h>
/** Hashing **/
size_t objects_hash_hash (objects_hash_t * hash);
/** Creating **/
objects_hash_t * objects_hash_alloc (void);
objects_hash_t * objects_hash_alloc_with_allocs (objects_allocs_t alloc);
objects_hash_t * objects_hash_with_callbacks (objects_callbacks_t callbacks);
objects_hash_t * objects_hash_with_allocs (objects_allocs_t allocs);
objects_hash_t * objects_hash_with_allocs_with_callbacks (objects_allocs_t allocs, objects_callbacks_t callbacks);
objects_hash_t * objects_hash_of_char_p (void);
objects_hash_t * objects_hash_of_void_p (void);
objects_hash_t * objects_hash_of_owned_void_p (void);
objects_hash_t * objects_hash_of_int (void);
objects_hash_t * objects_hash_of_id (void);
/** Initializing **/
objects_hash_t * objects_hash_init (objects_hash_t * hash);
objects_hash_t * objects_hash_init_with_callbacks (objects_hash_t * hash, objects_callbacks_t callbacks);
objects_hash_t * objects_hash_init_with_hash (objects_hash_t * hash, objects_hash_t * other_hash);
/** Copying **/
objects_hash_t * objects_hash_copy (objects_hash_t * old_hash);
objects_hash_t * objects_hash_copy_with_allocs (objects_hash_t * hash, objects_allocs_t new_allocs);
/** Mapping **/
/* WARNING: The mapping function FCN must be one-to-one on elements of
* HASH. I.e., for reasons of efficiency, `objects_hash_map_elements()'
* makes no provision for the possibility that FCN maps two unequal
* elements of HASH to the same (or equal) elements. The better way
* to handle functions that aren't one-to-one is to create a new hash
* and transform the elements of the first to create the elements of
* the second. */
objects_hash_t * objects_hash_map_elements (objects_hash_t * hash, void *(*fcn) (void *, void *), void *user_data);
/** Destroying **/
void objects_hash_dealloc (objects_hash_t * hash);
/** Comparing **/
int objects_hash_contains_hash (objects_hash_t * hash, objects_hash_t * other_hash);
int objects_hash_intersects_hash (objects_hash_t * hash, objects_hash_t * other_hash);
int objects_hash_is_equal_to_hash (objects_hash_t * hash, objects_hash_t * other_hash);
/** Adding **/
void *objects_hash_add_element_known_absent (objects_hash_t * hash, void *element);
void *objects_hash_add_element (objects_hash_t * hash, void *element);
void *objects_hash_add_element_if_absent (objects_hash_t * hash, void *element);
/** Replacing **/
void objects_hash_replace_element (objects_hash_t * hash, void *element);
/** Removing **/
void objects_hash_remove_element (objects_hash_t * hash, void *element);
/** Emptying **/
void objects_hash_empty (objects_hash_t * hash);
/** Searching **/
void *objects_hash_any_element (objects_hash_t * hash);
int objects_hash_contains_element (objects_hash_t * hash, void *element);
void *objects_hash_element (objects_hash_t * hash, void *element);
void **objects_hash_all_elements (objects_hash_t * hash);
/** Enumerating **/
objects_hash_enumerator_t objects_hash_enumerator (objects_hash_t * hash);
int objects_hash_enumerator_next_element (objects_hash_enumerator_t *enumerator, void **element);
/** Statistics **/
int objects_hash_is_empty (objects_hash_t * hash);
size_t objects_hash_count (objects_hash_t * hash);
size_t objects_hash_capacity (objects_hash_t * hash);
int objects_hash_check (objects_hash_t * hash);
/** Miscellaneous **/
size_t objects_hash_resize (objects_hash_t * hash, size_t new_capacity);
size_t objects_hash_rightsize (objects_hash_t * hash);
objects_hash_t * objects_hash_intersect_hash (objects_hash_t * hash, objects_hash_t * other_hash);
objects_hash_t * objects_hash_minus_hash (objects_hash_t * hash, objects_hash_t * other_hash);
objects_hash_t * objects_hash_union_hash (objects_hash_t * hash, objects_hash_t * other_hash);
#endif /* __hash_h_OBJECTS_INCLUDE */

View file

@ -0,0 +1,252 @@
/* A list for use with Libobjects.
* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Tue Sep 5 17:25:59 EDT 1995
* Updated: Sat Feb 10 15:37:41 EST 1996
* Serial: 96.02.10.01
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __list_h_OBJECTS_INCLUDE
#define __list_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
#include <objects/allocs.h>
#include <objects/callbacks.h>
#include <objects/hash.h>
#include <objects/array.h>
/**** Type, Constant, and Macro Definitions **********************************/
typedef struct _objects_list objects_list_t;
typedef struct _objects_list_node objects_list_node_t;
typedef struct _objects_list_enumerator objects_list_enumerator_t;
struct _objects_list_node
{
objects_list_t * list;
objects_list_node_t *next_in_list;
objects_list_node_t *prev_in_list;
void *element;
};
struct _objects_list
{
/* Container identifiers */
int magic;
size_t number;
char *name;
void *extra;
objects_callbacks_t extra_callbacks;
objects_allocs_t allocs;
/* Element callbacks */
objects_callbacks_t callbacks;
/* Internal counters */
size_t node_count;
size_t element_count;
/* Databanks */
objects_list_node_t *first_node;
objects_list_node_t *last_node;
};
struct _objects_list_enumerator
{
objects_list_t *list;
objects_list_node_t *node;
size_t forward;
};
/**** Function Prototypes ****************************************************/
/** Basics **/
#include <objects/list-basics.h>
#include <objects/list-callbacks.h>
/** Creating **/
objects_list_t * objects_list_alloc (void);
objects_list_t * objects_list_alloc_with_allocs (objects_allocs_t allocs);
objects_list_t * objects_list_with_allocs (objects_allocs_t allocs);
objects_list_t * objects_list_with_callbacks (objects_callbacks_t callbacks);
objects_list_t * objects_list_with_allocs_with_callbacks (objects_allocs_t allocs, objects_callbacks_t callbacks);
objects_list_t * objects_list_of_char_p (void);
objects_list_t * objects_list_of_void_p (void);
objects_list_t * objects_list_of_owned_void_p (void);
objects_list_t * objects_list_of_int (void);
objects_list_t * objects_list_of_int_p (void);
objects_list_t * objects_list_of_id (void);
/** Initializing **/
objects_list_t * objects_list_init (objects_list_t * list);
objects_list_t * objects_list_init_with_callbacks (objects_list_t * list, objects_callbacks_t callbacks);
/** Copying **/
objects_list_t * objects_list_copy (objects_list_t * old_list);
objects_list_t * objects_list_copy_with_allocs (objects_list_t * old_list, objects_allocs_t allocs);
/** Destroying **/
void objects_list_dealloc (objects_list_t * list);
/** Comparing **/
int objects_list_is_equal_to_list (objects_list_t * list, objects_list_t * other_list);
/** Concatenating **/
objects_list_t * objects_list_append_list (objects_list_t * base_list, objects_list_t * suffix_list);
objects_list_t * objects_list_prepend_list (objects_list_t * base_list, objects_list_t * prefix_list);
objects_list_t * objects_list_at_index_insert_list (objects_list_t * base_list, long int n, objects_list_t * infix_list);
/** Permuting **/
objects_list_t * objects_list_roll_to_nth_element (objects_list_t * list, long int n);
objects_list_t * objects_list_roll_to_element (objects_list_t * list, void *element);
objects_list_t * objects_list_roll_to_nth_occurrance_of_element (objects_list_t * list, long int n, void *element);
objects_list_t * objects_list_invert (objects_list_t * list);
objects_list_t * objects_list_swap_elements_at_indices (objects_list_t * list, long int m, long int n);
/** Adding **/
void *objects_list_append_element (objects_list_t * list, void *element);
void *objects_list_append_element_if_absent (objects_list_t * list, void *element);
void *objects_list_prepend_element (objects_list_t * list, void *element);
void *objects_list_prepend_element_if_absent (objects_list_t * list, void *element);
void *objects_list_at_index_insert_element (objects_list_t * list, long int n, void *element);
void *objects_list_at_index_insert_element_if_absent (objects_list_t * list, long int n, void *element);
void *objects_list_queue_push_element (objects_list_t * list, void *element);
void *objects_list_stack_push_element (objects_list_t * list, void *element);
/** Replacing **/
void objects_list_replace_nth_occurrance_of_element (objects_list_t * list, long int n, void *old_element, void *new_element);
void objects_list_replace_element (objects_list_t * list, void *old_element, void *new_element);
void objects_list_replace_nth_element (objects_list_t * list, long int n, void *new_element);
void objects_list_replace_first_element (objects_list_t * list, void *new_element);
void objects_list_replace_last_element (objects_list_t * list, void *new_element);
/** Removing **/
void objects_list_remove_nth_occurrence_of_element (objects_list_t * list, long int n, void *element);
void objects_list_remove_element (objects_list_t * list, void *element);
void objects_list_remove_nth_element (objects_list_t * list, long int n);
void objects_list_remove_first_element (objects_list_t * list);
void objects_list_remove_last_element (objects_list_t * list);
void objects_list_queue_pop_element (objects_list_t * list);
void objects_list_queue_pop_nth_element (objects_list_t * list, long int n);
void objects_list_stack_pop_element (objects_list_t * list);
void objects_list_stack_pop_nth_element (objects_list_t * list, long int n);
/** Emptying **/
void objects_list_empty (objects_list_t * list);
/** Searching **/
int objects_list_contains_element (objects_list_t * list, void *element);
void *objects_list_element (objects_list_t * list, void *element);
void *objects_list_nth_element (objects_list_t * list, long int n);
void *objects_list_first_element (objects_list_t * list);
void *objects_list_last_element (objects_list_t * list);
void **objects_list_all_elements (objects_list_t * list);
/** Enumerating **/
objects_list_enumerator_t objects_list_enumerator (objects_list_t * list);
objects_list_enumerator_t objects_list_forward_enumerator (objects_list_t * list);
objects_list_enumerator_t objects_list_reverse_enumerator (objects_list_t * list);
int objects_list_enumerator_next_element (objects_list_enumerator_t *enumerator, void **element);
/** Mapping **/
/* NO WARNING: The mapping function FCN need not be one-to-one on the
* elements of LIST. In fact, FCN may do whatever it likes. */
objects_list_t * objects_list_map_elements (objects_list_t * list, void *(*fcn) (void *, void *), void *user_data);
/** Statistics **/
int objects_list_is_empty (objects_list_t * list);
size_t objects_list_count (objects_list_t * list);
size_t objects_list_capacity (objects_list_t * list);
int objects_list_check (objects_list_t * list);
/** Miscellaneous **/
objects_hash_t *objects_hash_init_from_list (objects_hash_t *hash, objects_list_t * list);
#endif /* __list_h_OBJECTS_INCLUDE */

View file

@ -0,0 +1,330 @@
/* A map table for use with Libobjects.
* Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: ??? ??? ?? ??:??:?? ??? 1993
* Updated: Sat Feb 10 13:36:59 EST 1996
* Serial: 96.02.10.01
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __map_h_OBJECTS_INCLUDE
#define __map_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
#include <objects/allocs.h>
#include <objects/callbacks.h>
#include <objects/hash.h>
/**** Type, Constant, and Macro Definitions **********************************/
typedef struct _objects_map objects_map_t;
typedef struct _objects_map_bucket objects_map_bucket_t;
typedef struct _objects_map_node objects_map_node_t;
typedef struct _objects_map_enumerator objects_map_enumerator_t;
/* Important structures... */
struct _objects_map_node
{
void *key;
void *value;
objects_map_bucket_t *bucket;
objects_map_t *map;
objects_map_node_t *next_in_bucket;
objects_map_node_t *prev_in_bucket;
objects_map_node_t *next_in_map;
objects_map_node_t *prev_in_map;
};
struct _objects_map_bucket
{
size_t node_count;
size_t element_count;
objects_map_node_t *first_node;
};
struct _objects_map
{
/* Container identifiers */
int magic;
size_t number;
char *name;
void *extra;
objects_callbacks_t extra_callbacks;
objects_allocs_t allocs;
objects_callbacks_t key_callbacks;
/* Management information */
objects_callbacks_t value_callbacks;
/* Internal counters */
size_t bucket_count;
size_t node_count;
size_t element_count;
/* Databanks */
objects_map_bucket_t *buckets;
objects_map_node_t *first_node;
};
struct _objects_map_enumerator
{
objects_map_t *map;
objects_map_node_t *node;
};
/**** Function Prototypes ****************************************************/
/** Basics **/
#include <objects/map-basics.h>
#include <objects/map-callbacks.h>
/** Altering capacity **/
size_t
objects_map_resize (objects_map_t * map, size_t new_capacity);
size_t
objects_map_rightsize (objects_map_t * map);
/** Creating **/
objects_map_t *
objects_map_alloc (void);
objects_map_t *
objects_map_alloc_with_allocs (objects_allocs_t allocs);
objects_map_t *
objects_map (void);
objects_map_t *
objects_map_with_allocs (objects_allocs_t allocs);
objects_map_t *
objects_map_with_allocs_with_callbacks (objects_allocs_t allocs,
objects_callbacks_t key_callbacks,
objects_callbacks_t value_callbacks);
objects_map_t *
objects_map_with_callbacks (objects_callbacks_t key_callbacks,
objects_callbacks_t value_callbacks);
objects_map_t *
objects_map_of_int (void);
objects_map_t *
objects_map_of_int_to_char_p (void);
objects_map_t *
objects_map_of_int_to_void_p (void);
objects_map_t *
objects_map_of_int_to_float (void);
objects_map_t *
objects_map_of_char_p (void);
objects_map_t *
objects_map_of_char_p_to_int (void);
objects_map_t *
objects_map_of_char_p_to_void_p (void);
objects_map_t *
objects_map_of_char_p_to_float (void);
objects_map_t *
objects_map_of_void_p (void);
objects_map_t *
objects_map_of_void_p_to_int (void);
objects_map_t *
objects_map_of_void_p_to_char_p (void);
objects_map_t *
objects_map_of_void_p_to_float (void);
objects_map_t *
objects_map_of_float (void);
objects_map_t *
objects_map_of_double (void);
/** Initializing **/
objects_map_t *
objects_map_init (objects_map_t * map);
objects_map_t *
objects_map_init_with_callbacks (objects_map_t * map,
objects_callbacks_t key_callbacks,
objects_callbacks_t value_callbacks);
/** Destroying **/
void
objects_map_dealloc (objects_map_t * map);
/** Gathering statistics on a mapionary **/
size_t
objects_map_pair_count (objects_map_t * map);
size_t
objects_map_capacity (objects_map_t * map);
int
objects_map_check_map (objects_map_t * map);
/** Finding elements in a mapionary **/
int
objects_map_contains_key (objects_map_t * map, void *key);
int
objects_map_key_and_value (objects_map_t * map,
void *key,
void **old_key,
void **value);
void *
objects_map_key (objects_map_t * map, void *key);
void *
objects_map_value (objects_map_t * map, void *key);
/** Enumerating the nodes and elements of a mapionary **/
objects_map_enumerator_t
objects_map_enumerator (objects_map_t * map);
int
objects_map_enumerator_next_key_and_value (objects_map_enumerator_t * enumerator,
void **key,
void **value);
int
objects_map_enumerator_next_key (objects_map_enumerator_t * enumerator,
void **key);
int
objects_map_enumerator_next_value (objects_map_enumerator_t * enumerator,
void **value);
/** Obtaining an array of the elements of a mapionary **/
void **
objects_map_all_keys_and_values (objects_map_t * map);
void **
objects_map_all_keys (objects_map_t * map);
void **
objects_map_all_values (objects_map_t * map);
/** Removing **/
void
objects_map_remove_key (objects_map_t * map, void *key);
void
objects_map_empty (objects_map_t * map);
/** Adding **/
void *
objects_map_at_key_put_value_known_absent (objects_map_t * map,
void *key,
void *value);
void *
objects_map_at_key_put_value (objects_map_t * map,
void *key,
void *value);
void *
objects_map_at_key_put_value_if_absent (objects_map_t * map,
void *key,
void *value);
/** Replacing **/
void
objects_map_replace_key (objects_map_t * map, void *key);
/** Comparing **/
int
objects_map_contains_map (objects_map_t * map1, objects_map_t * map2);
int
objects_map_is_equal_to_map (objects_map_t * map1, objects_map_t * map2);
/** Copying **/
objects_map_t *
objects_map_copy_with_allocs (objects_map_t * old_map, objects_allocs_t new_allocs);
objects_map_t *
objects_map_copy (objects_map_t * old_map);
/** Mapping **/
/* WARNING: The mapping function KFCN must be one-to-one on the keys
* of MAP. I.e., `objects_map_map_keys()' makes no provision for the
* possibility that KFCN maps two unequal keys of MAP to the same (or
* equal) keys. */
objects_map_t *
objects_map_map_keys (objects_map_t * map,
void *(*kfcn) (void *, void *),
void *user_data);
/* NO WARNING: The mapping function VFCN need not be one-to-one on
* (the equivalence classes of) values. */
objects_map_t *
objects_map_map_values (objects_map_t * map,
void *(*vfcn) (void *, void *),
void *user_data);
/** Miscellaneous **/
objects_map_t *
objects_map_intersect_map (objects_map_t * map, objects_map_t * other_map);
objects_map_t *
objects_map_minus_map (objects_map_t * map, objects_map_t * other_map);
objects_map_t *
objects_map_union_map (objects_map_t * map, objects_map_t * other_map);
objects_hash_t *
objects_hash_init_from_map_keys (objects_hash_t * hash, objects_map_t * map);
objects_hash_t *
objects_hash_init_from_map_values (objects_hash_t * hash, objects_map_t * map);
#endif /* __map_h_OBJECTS_INCLUDE */

41
Source/objects/abort.h Normal file
View file

@ -0,0 +1,41 @@
/* A hookable abort function for Libobjects.
* Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Sat Feb 10 12:34:27 EST 1996
* Updated: Sat Feb 10 15:49:43 EST 1996
* Serial: 96.02.10.03
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __abort_h_OBJECTS_INCLUDE
#define __abort_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
/**** Type, Constant, and Macro Definitions **********************************/
extern void (*__objects_abort) (void);
/**** Function Prototypes ****************************************************/
void objects_abort (void);
#endif /* __abort_h_OBJECTS_INCLUDE */

82
Source/objects/allocs.h Normal file
View file

@ -0,0 +1,82 @@
/* Modular memory management. Better living through chemicals.
* Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Thu Oct 13 23:46:02 EDT 1994
* Updated: Sat Feb 10 15:47:25 EST 1996
* Serial: 96.02.10.01
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __allocs_h_OBJECTS_INCLUDE
#define __allocs_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
#include <stdlib.h>
/**** Type, Constant, and Macro Definitions **********************************/
typedef void *(*objects_malloc_func_t) (size_t, void *);
typedef void *(*objects_calloc_func_t) (size_t, size_t, void *);
typedef void *(*objects_realloc_func_t) (void *, size_t, void *);
typedef void (*objects_free_func_t) (void *, void *);
typedef struct _objects_allocs objects_allocs_t;
struct _objects_allocs
{
objects_malloc_func_t malloc;
objects_calloc_func_t calloc;
objects_realloc_func_t realloc;
objects_free_func_t free;
void *user_data;
};
/* Shorthand macros. */
#define OBJECTS_MALLOC(S) objects_malloc(objects_standard_allocs(), (S))
#define OBJECTS_CALLOC(N, S) objects_calloc(objects_standard_allocs(), (N), (S))
#define OBJECTS_REALLOC(P, S) objects_realloc(objects_standard_allocs(), (P), (S))
#define OBJECTS_FREE(P) objects_free(objects_standard_allocs(), (P))
/* Change these if you need different default allocs. */
extern objects_allocs_t __objects_allocs_standard;
/**** Function Prototypes ****************************************************/
/* Returns `__objects_allocs_standard', defined above. */
objects_allocs_t
objects_allocs_standard (void);
void *
objects_malloc (objects_allocs_t allocs, size_t s);
void *
objects_calloc (objects_allocs_t allocs, size_t n, size_t s);
void *
objects_realloc (objects_allocs_t allocs, void *p, size_t s);
void
objects_free (objects_allocs_t allocs, void *p);
size_t
objects_next_power_of_two (size_t start);
#endif /* __allocs_h_OBJECTS_INCLUDE */

198
Source/objects/array.h Normal file
View file

@ -0,0 +1,198 @@
/* A sparse array for use with Libobjects.
* Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Thu Mar 2 02:30:02 EST 1994
* Updated: Sat Feb 10 15:38:58 EST 1996
* Serial: 96.02.10.01
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __array_h_OBJECTS_INCLUDE
#define __array_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
#include <stdlib.h>
#include <objects/allocs.h>
#include <objects/callbacks.h>
#include <objects/hash.h>
/**** Type, Constant, and Macro Definitions **********************************/
typedef struct _objects_array objects_array_t;
typedef struct _objects_array_bucket objects_array_bucket_t;
typedef objects_array_bucket_t *objects_array_slot_t;
typedef struct _objects_array_enumerator objects_array_enumerator_t;
struct _objects_array_bucket
{
/* The bucket's real (or external) index */
size_t index;
/* The bucket's cargo */
void *element;
};
struct _objects_array
{
/* Identifying information. */
int magic;
size_t number;
char *name;
void *extra;
objects_callbacks_t extra_callbacks;
objects_allocs_t allocs;
/* Callbacks for the items in the array. */
objects_callbacks_t callbacks;
/* Internal counters */
size_t slot_count;
size_t element_count;
/* Databanks */
objects_array_slot_t *slots;
objects_array_slot_t *sorted_slots;
};
struct _objects_array_enumerator
{
objects_array_t * array;
size_t index;
int is_sorted;
int is_ascending;
};
/**** Function Prototypes ****************************************************/
/** Basics **/
#include <objects/array-basics.h>
#include <objects/array-callbacks.h>
/** Creating **/
objects_array_t * objects_array_alloc (void);
objects_array_t * objects_array_alloc_with_allocs (objects_allocs_t allocs);
objects_array_t * objects_array (void);
objects_array_t * objects_array_with_allocs (objects_allocs_t allocs);
objects_array_t * objects_array_with_allocs_with_callbacks (objects_allocs_t allocs, objects_callbacks_t callbacks);
objects_array_t * objects_array_with_callbacks (objects_callbacks_t callbacks);
objects_array_t * objects_array_of_char_p (void);
objects_array_t * objects_array_of_void_p (void);
objects_array_t * objects_array_of_owned_void_p (void);
objects_array_t * objects_array_of_int (void);
objects_array_t * objects_array_of_id (void);
/** Initializing **/
objects_array_t * objects_array_init (objects_array_t * array);
objects_array_t * objects_array_init_with_callbacks (objects_array_t * array, objects_callbacks_t callbacks);
objects_array_t * objects_array_init_with_array (objects_array_t * array, objects_array_t * other_array);
/** Copying **/
objects_array_t * objects_array_copy (objects_array_t * array);
objects_array_t * objects_array_copy_with_allocs (objects_array_t * array, objects_allocs_t allocs);
/** Destroying **/
void objects_array_dealloc (objects_array_t * array);
/** Comparing **/
int objects_array_is_equal_to_array (objects_array_t * array, objects_array_t * other_array);
/** Adding **/
void *objects_array_at_index_put_element (objects_array_t * array, size_t index, void *element);
/** Replacing **/
/** Removing **/
void objects_array_remove_element_at_index (objects_array_t * array, size_t index);
void objects_array_remove_element (objects_array_t * array, void *element);
void objects_array_remove_element_known_present (objects_array_t * array, void *element);
/** Emptying **/
void objects_array_empty (objects_array_t * array);
/** Searching **/
int objects_array_contains_element (objects_array_t * array, void *element);
void *objects_array_element (objects_array_t * array, void *element);
size_t objects_array_index_of_element (objects_array_t * array, void *element);
void *objects_array_element_at_index (objects_array_t * array, size_t index);
void **objects_array_all_elements (objects_array_t * array);
void **objects_array_all_elements_ascending (objects_array_t * array);
void **objects_array_all_element_descending (objects_array_t * array);
/** Enumerating **/
objects_array_enumerator_t objects_array_enumerator (objects_array_t * array);
objects_array_enumerator_t objects_array_ascending_enumerator (objects_array_t * array);
objects_array_enumerator_t objects_array_descending_enumerator (objects_array_t * array);
int objects_array_enumerator_next_index_and_element (objects_array_enumerator_t *enumerator, size_t *index, void **element);
int objects_array_enumerator_next_element (objects_array_enumerator_t *enumerator, void **element);
int objects_array_enumerator_next_index (objects_array_enumerator_t *enumerator, size_t *element);
/** Statistics **/
int objects_array_is_empty (objects_array_t * array);
size_t objects_array_count (objects_array_t * array);
size_t objects_array_capacity (objects_array_t * array);
int objects_array_check (objects_array_t * array);
/** Miscellaneous **/
objects_hash_t *objects_hash_init_from_array (objects_hash_t *hash, objects_array_t *array);
#endif /* __array_h_OBJECTS_INCLUDE */

59
Source/objects/bitops.h Normal file
View file

@ -0,0 +1,59 @@
/* Macros for bit-wise operations.
* Copyright (C) 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Sat Feb 10 21:17:10 EST 1996
* Updated: Sat Feb 10 21:17:10 EST 1996
* Serial: 96.02.10.01
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
/**** Included Headers *******************************************************/
#include <objects/callbacks.h>
/**** Type, Constant, and Macro Definitions **********************************/
/**** Function Implementations ***********************************************/
#ifndef __bits_h_OBJECTS_INCLUDE
#define __bits_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
/**** Type, Constant, and Macro Definitions **********************************/
/** Bit operations **/
/* Set the Nth bit of V to one. */
#define OBJECTS_BIT_POKE(V,N) ((V) |= (1 << (N)))
/* Set the Nth bit of V to zero. */
#define OBJECTS_BIT_NOCK(V,N) ((V) &= ~(1 << (N)))
/* Toggle the Nth bit of V. */
#define OBJECTS_BIT_PLUK(V,N) ((V) ^= (1 << (N)))
/* Grab the Nth bit of V. */
#define OBJECTS_BIT_PEEK(V,N) ((V) & (1 << (N)))
/**** Function Prototypes ****************************************************/
#endif /* __bits_h_OBJECTS_INCLUDE */

172
Source/objects/callbacks.h Normal file
View file

@ -0,0 +1,172 @@
/* Handling various types in a uniform manner.
* Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Sun Oct 9 13:18:50 EDT 1994
* Updated: Sun Feb 11 01:46:03 EST 1996
* Serial: 96.02.11.01
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __callbacks_h_OBJECTS_INCLUDE
#define __callbacks_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
#include <stdlib.h>
/**** Type, Constant, and Macro Definitions **********************************/
typedef size_t (*objects_hash_func_t) (void *, void *);
typedef int (*objects_compare_func_t) (void *, void *, void *);
typedef int (*objects_is_equal_func_t) (void *, void *, void *);
typedef void *(*objects_retain_func_t) (void *, void *);
typedef void (*objects_release_func_t) (void *, void *);
typedef void *(*objects_describe_func_t) (void *, void *);
typedef struct _objects_callbacks objects_callbacks_t;
struct _objects_callbacks
{
objects_hash_func_t hash;
objects_compare_func_t compare;
objects_is_equal_func_t is_equal;
objects_retain_func_t retain;
objects_release_func_t release;
objects_describe_func_t describe;
void *not_an_item_marker;
};
/** Callbacks for various types **/
extern const objects_callbacks_t objects_callbacks_for_int;
extern const objects_callbacks_t objects_callbacks_for_char_p;
extern const objects_callbacks_t objects_callbacks_for_void_p;
extern const objects_callbacks_t objects_callbacks_for_owned_void_p;
extern const objects_callbacks_t objects_callbacks_for_int_p;
extern const objects_callbacks_t objects_callbacks_for_id;
/* FIXME: I need to figure out what each of these should be. Hmmm? */
extern const void *objects_not_an_int_marker;
extern const void *objects_not_a_char_p_marker;
extern const void *objects_not_a_void_p_marker;
extern const void *objects_not_an_int_p_marker;
extern const void *objects_not_an_id_marker;
/* Change this if you need different default callbacks. */
extern objects_callbacks_t __objects_callbacks_standard;
/**** Function Prototypes ****************************************************/
/** Generic callbacks **/
/* Returns `__objects_callbacks_standard', defined above. */
objects_callbacks_t
objects_callbacks_standard (void);
/** Standardizing callbacks **/
objects_callbacks_t
objects_callbacks_standardize (objects_callbacks_t callbacks);
/** Using callbacks **/
size_t objects_hash (objects_callbacks_t callbacks,
void *thing,
void *user_data);
int objects_compare (objects_callbacks_t callbacks,
void *thing1,
void *thing2,
void *user_data);
int objects_is_equal (objects_callbacks_t callbacks,
void *thing1,
void *thing2,
void *user_data);
void *objects_retain (objects_callbacks_t callbacks,
void *thing,
void *user_data);
void objects_release (objects_callbacks_t callbacks,
void *thing,
void *user_data);
/* FIXME: Decide what to do with this describe stuff. We'd really like
* them to return Strings? Or would we rather they be `char *'s?
* Or something else? */
void *objects_describe (objects_callbacks_t callbacks,
void *thing,
void *user_data);
void *objects_not_an_item_marker (objects_callbacks_t);
/** Specific callback functions **/
/* For `void *' */
size_t objects_void_p_hash(void *ptr);
int objects_void_p_compare(void *ptr, void *qtr);
int objects_void_p_is_equal(void *ptr, void *qtr);
void *objects_void_p_retain(void *ptr);
void objects_void_p_release(void *ptr);
void *objects_void_p_describe(void *ptr);
/* For `void *' */
size_t objects_owned_void_p_hash(void *ptr);
int objects_owned_void_p_compare(void *ptr, void *qtr);
int objects_owned_void_p_is_equal(void *ptr, void *qtr);
void *objects_owned_void_p_retain(void *ptr);
void objects_owned_void_p_release(void *ptr);
void *objects_owned_void_p_describe(void *ptr);
/* For `int' */
size_t objects_int_hash(void *i);
int objects_int_compare(void *i, void *j);
int objects_int_is_equal(void *i, void *j);
void *objects_int_retain(void *i);
void objects_int_release(void *i);
void *objects_int_describe(void *i);
/* For `int *' */
size_t objects_int_p_hash(void *iptr);
int objects_int_p_compare(void *iptr, void *jptr);
int objects_int_p_is_equal(void *iptr, void *jptr);
void *objects_int_p_retain(void *iptr);
void objects_int_p_release(void *iptr);
void *objects_int_p_describe(void *iptr);
/* For `char *' */
size_t objects_char_p_hash(void *cptr);
int objects_char_p_compare(void *cptr, void *dptr);
int objects_char_p_is_equal(void *cptr, void *dptr);
void *objects_char_p_retain(void *cptr);
void objects_char_p_release(void *cptr);
void *objects_char_p_describe(void *cptr);
/* For `id' */
size_t objects_id_hash(void *obj);
int objects_id_compare(void *obj, void *jbo);
int objects_id_is_equal(void *obj, void *jbo);
void *objects_id_retain(void *obj);
void objects_id_release(void *obj);
void *objects_id_describe(void *obj);
#endif /* __callbacks_h_OBJECTS_INCLUDE */

241
Source/objects/data.h Normal file
View file

@ -0,0 +1,241 @@
/* A modular data encapsulator for use with Libobjects.
* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Fri Nov 24 21:50:01 EST 1995
* Updated: Sat Feb 10 15:40:21 EST 1996
* Serial: 96.02.10.01
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __data_h_OBJECTS_INCLUDE
#define __data_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
#include <objects/allocs.h>
#include <objects/callbacks.h>
/**** Type, Constant, and Macro Definitions **********************************/
typedef enum _objects_data_encoding objects_data_encoding_t;
enum _objects_data_encoding
{
objects_data_encoding_unknown = -1,
objects_data_encoding_binary,
objects_data_encoding_7bit,
objects_data_encoding_8bit,
objects_data_encoding_base64,
objects_data_encoding_quoted_printable,
objects_data_encoding_x_uuencode
};
typedef struct _objects_data objects_data_t;
struct _objects_data
{
int magic;
size_t number;
char *name;
void *extra;
objects_callbacks_t extra_callbacks;
objects_allocs_t allocs;
/* Necessary information about the data. */
void *buffer; /* Where the stuff really is. */
size_t length; /* How much stuff there is. */
size_t capacity; /* How much room for stuff there is. */
};
/* Creating temporary data. This is *so* cool. GCC is awesome! */
#define OBJECTS_DATA(P, L) \
(objects_data_t *(&({OBJECTS_MAGIC_DATA, (size_t) -1, 0, \
0, 0, __objects_callbacks_standard, 0, 0, 0, \
__objects_allocs_standard, (P), (L), (L)})))
/**** Function Prototypes ****************************************************/
/** Basics **/
#include <objects/data-basics.h>
/** Hashing **/
size_t objects_data_hash (objects_data_t * data);
/** Creating **/
objects_data_t * objects_data_alloc (void);
objects_data_t * objects_data_alloc_with_allocs (objects_allocs_t allocs);
objects_data_t * objects_data_new (void);
objects_data_t * objects_data_new_with_allocs (objects_allocs_t allocs);
objects_data_t * _objects_data_with_allocs_with_contents_of_file (objects_allocs_t allocs, const char *file);
objects_data_t * _objects_data_with_contents_of_file (const char *file);
objects_data_t * objects_data_with_buffer_of_length (void *buffer, size_t length);
objects_data_t * objects_data_with_allocs_with_buffer_of_length (objects_allocs_t allocs, void *buffer, size_t length);
/** Initializing **/
objects_data_t * objects_data_init (objects_data_t * data);
objects_data_t * _objects_data_init_with_contents_of_file (objects_data_t * data, const char *file);
objects_data_t * objects_data_init_with_buffer_of_length (objects_data_t * data, void *buffer, size_t length);
/** Statistics **/
size_t objects_data_capacity (objects_data_t * data);
/* Obtain DATA's length. */
size_t objects_data_length (objects_data_t * data);
/* Obtain a read-only copy of DATA's buffer. */
const void *objects_data_buffer (objects_data_t * data);
/* Obtain DATA's capacity through reference. */
size_t objects_data_get_capacity (objects_data_t * data, size_t * capacity);
/* Obtain DATA's length through reference. */
size_t objects_data_get_length (objects_data_t * data, size_t * length);
/* Copy DATA's buffer into BUFFER. It is assumed that BUFFER is large
* enough to contain DATA's buffer. */
size_t objects_data_get_buffer (objects_data_t * data, void *buffer);
/* Copy no more that LENGTH of DATA's buffer into BUFFER. Returns the
* amount actually copied. */
size_t objects_data_get_buffer_of_length (objects_data_t * data, void *buffer, size_t length);
/* Copy a subrange of DATA's buffer into BUFFER. As always, it is
* assumed that BUFFER is large enough to contain everything. We
* return the size of the data actually copied into BUFFER. */
size_t objects_data_get_buffer_of_subrange (objects_data_t * data, void *buffer, size_t location, size_t length);
size_t objects_data_set_capacity (objects_data_t * data, size_t capacity);
size_t objects_data_increase_capacity (objects_data_t * data, size_t capacity);
size_t objects_data_decrease_capacity (objects_data_t * data, size_t capacity);
size_t objects_data_set_length (objects_data_t * data, size_t length);
size_t objects_data_set_buffer_of_subrange (objects_data_t * data, void *buffer, size_t location, size_t length);
size_t objects_data_set_buffer_of_length (objects_data_t * data, void *buffer, size_t length);
void objects_data_get_md5_checksum (objects_data_t * data, char *buffer);
/** Copying **/
objects_data_t * objects_data_copy (objects_data_t * data);
objects_data_t * objects_data_copy_of_subrange (objects_data_t * data, size_t location, size_t length);
objects_data_t * objects_data_copy_with_allocs (objects_data_t * data, objects_allocs_t allocs);
objects_data_t * objects_data_copy_of_subrange_with_allocs (objects_data_t * data, size_t location, size_t length, objects_allocs_t allocs);
/** Replacing **/
/* Note that we cannot do any bounds checking on BUFFER. */
objects_data_t * objects_data_replace_subrange_with_subrange_of_buffer (objects_data_t * data, size_t location, size_t length, size_t buf_location, size_t buf_length, void *buffer);
objects_data_t * objects_data_replace_subrange_with_subrange_of_data (objects_data_t * data, size_t location, size_t length, size_t other_location, size_t other_length, objects_data_t * other_data);
objects_data_t * objects_data_replace_subrange_with_data (objects_data_t * data, size_t location, size_t length, objects_data_t * other_data);
/** Appending **/
objects_data_t * objects_data_append_data (objects_data_t * data, objects_data_t * other_data);
objects_data_t * objects_data_append_subrange_of_data (objects_data_t * data, size_t location, size_t length, objects_data_t * other_data);
objects_data_t * objects_data_append_data_repeatedly (objects_data_t * data, objects_data_t * other_data, size_t num_times);
objects_data_t * objects_data_append_subrange_of_data_repeatedly (objects_data_t * data, size_t location, size_t length, objects_data_t * other_data, size_t num_times);
/** Prepending **/
objects_data_t * objects_data_prepend_data (objects_data_t * data, objects_data_t * other_data);
objects_data_t * objects_data_prepend_subrange_of_data (objects_data_t * data, size_t location, size_t length, objects_data_t * other_data);
objects_data_t * objects_data_prepend_data_repeatedly (objects_data_t * data, objects_data_t * other_data, size_t num_times);
objects_data_t * objects_data_prepend_subrange_of_data_repeatedly (objects_data_t * data, size_t location, size_t length, objects_data_t * other_data, size_t num_times);
/** Concatenating **/
objects_data_t * objects_data_concatenate_data (objects_data_t * data, objects_data_t * other_data);
objects_data_t * objects_data_concatenate_data_with_allocs (objects_data_t * data, objects_data_t * other_data, objects_allocs_t allocs);
objects_data_t * objects_data_concatenate_subrange_of_data (objects_data_t * data, size_t location, size_t length, objects_data_t * other_data);
objects_data_t * objects_data_concatenate_subrange_of_data_with_allocs (objects_data_t * data, size_t location, size_t length, objects_data_t * other_data, objects_allocs_t allocs);
/** Reversing **/
objects_data_t * objects_data_reverse_with_granularity (objects_data_t * data, size_t granularity);
objects_data_t * objects_data_reverse_by_int (objects_data_t * data);
objects_data_t * objects_data_reverse_by_char (objects_data_t * data);
objects_data_t * objects_data_reverse_by_void_p (objects_data_t * data);
/** Permuting **/
objects_data_t * objects_data_permute_with_granularity (objects_data_t * data, size_t granularity);
objects_data_t * objects_data_permute_with_no_fixed_points_with_granularity (objects_data_t * data, size_t granularity);
/** Writing **/
int _objects_data_write_to_file (objects_data_t * data, const char *file);
/** Encoding **/
objects_data_encoding_t objects_data_guess_data_encoding (objects_data_t * data);
objects_data_t * _objects_data_encode_with_base64 (objects_data_t * data);
objects_data_t * _objects_data_encode_with_quoted_printable (objects_data_t * data);
objects_data_t * _objects_data_encode_with_x_uuencode (objects_data_t * data);
objects_data_t * objects_data_encode_with_encoding (objects_data_t * data, objects_data_encoding_t enc);
objects_data_t * _objects_data_decode_with_base64 (objects_data_t * data);
objects_data_t * _objects_data_decode_with_quoted_printable (objects_data_t * data);
objects_data_t * _objects_data_decode_with_x_uuencode (objects_data_t * data);
objects_data_t * objects_data_decode_with_encoding (objects_data_t * data, objects_data_encoding_t enc);
#endif /* __data_h_OBJECTS_INCLUDE */

220
Source/objects/hash.h Normal file
View file

@ -0,0 +1,220 @@
/* A hash table for use with Libobjects.
* Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: ??? ??? ?? ??:??:?? ??? 1993
* Updated: Sat Feb 10 15:35:37 EST 1996
* Serial: 96.02.10.01
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __hash_h_OBJECTS_INCLUDE
#define __hash_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
#include <objects/allocs.h>
#include <objects/callbacks.h>
/**** Type, Constant, and Macro Definitions **********************************/
typedef struct _objects_hash objects_hash_t;
typedef struct _objects_hash_bucket objects_hash_bucket_t;
typedef struct _objects_hash_node objects_hash_node_t;
typedef struct _objects_hash_enumerator objects_hash_enumerator_t;
struct _objects_hash_node
{
objects_hash_t *hash;
objects_hash_bucket_t *bucket;
objects_hash_node_t *next_in_bucket;
objects_hash_node_t *prev_in_bucket;
objects_hash_node_t *next_in_hash;
objects_hash_node_t *prev_in_hash;
void *element;
};
struct _objects_hash_bucket
{
size_t node_count;
size_t element_count;
objects_hash_node_t *first_node;
};
struct _objects_hash
{
int magic;
size_t number;
char *name;
void *extra;
objects_callbacks_t extra_callbacks;
objects_allocs_t allocs;
/* Callbacks for the items in the hash. */
objects_callbacks_t callbacks;
/* Internal hash counters. */
size_t bucket_count; /* How many types of items? */
size_t node_count; /* How many items? */
size_t element_count; /* How many elements? */
/* Places to start looking for elements. */
objects_hash_bucket_t *buckets;
objects_hash_node_t *first_node;
};
struct _objects_hash_enumerator
{
objects_hash_t *hash;
objects_hash_node_t *node;
};
/**** Function Prototypes ****************************************************/
/** Basics **/
#include <objects/hash-basics.h>
#include <objects/hash-callbacks.h>
/** Hashing **/
size_t objects_hash_hash (objects_hash_t * hash);
/** Creating **/
objects_hash_t * objects_hash_alloc (void);
objects_hash_t * objects_hash_alloc_with_allocs (objects_allocs_t alloc);
objects_hash_t * objects_hash_with_callbacks (objects_callbacks_t callbacks);
objects_hash_t * objects_hash_with_allocs (objects_allocs_t allocs);
objects_hash_t * objects_hash_with_allocs_with_callbacks (objects_allocs_t allocs, objects_callbacks_t callbacks);
objects_hash_t * objects_hash_of_char_p (void);
objects_hash_t * objects_hash_of_void_p (void);
objects_hash_t * objects_hash_of_owned_void_p (void);
objects_hash_t * objects_hash_of_int (void);
objects_hash_t * objects_hash_of_id (void);
/** Initializing **/
objects_hash_t * objects_hash_init (objects_hash_t * hash);
objects_hash_t * objects_hash_init_with_callbacks (objects_hash_t * hash, objects_callbacks_t callbacks);
objects_hash_t * objects_hash_init_with_hash (objects_hash_t * hash, objects_hash_t * other_hash);
/** Copying **/
objects_hash_t * objects_hash_copy (objects_hash_t * old_hash);
objects_hash_t * objects_hash_copy_with_allocs (objects_hash_t * hash, objects_allocs_t new_allocs);
/** Mapping **/
/* WARNING: The mapping function FCN must be one-to-one on elements of
* HASH. I.e., for reasons of efficiency, `objects_hash_map_elements()'
* makes no provision for the possibility that FCN maps two unequal
* elements of HASH to the same (or equal) elements. The better way
* to handle functions that aren't one-to-one is to create a new hash
* and transform the elements of the first to create the elements of
* the second. */
objects_hash_t * objects_hash_map_elements (objects_hash_t * hash, void *(*fcn) (void *, void *), void *user_data);
/** Destroying **/
void objects_hash_dealloc (objects_hash_t * hash);
/** Comparing **/
int objects_hash_contains_hash (objects_hash_t * hash, objects_hash_t * other_hash);
int objects_hash_intersects_hash (objects_hash_t * hash, objects_hash_t * other_hash);
int objects_hash_is_equal_to_hash (objects_hash_t * hash, objects_hash_t * other_hash);
/** Adding **/
void *objects_hash_add_element_known_absent (objects_hash_t * hash, void *element);
void *objects_hash_add_element (objects_hash_t * hash, void *element);
void *objects_hash_add_element_if_absent (objects_hash_t * hash, void *element);
/** Replacing **/
void objects_hash_replace_element (objects_hash_t * hash, void *element);
/** Removing **/
void objects_hash_remove_element (objects_hash_t * hash, void *element);
/** Emptying **/
void objects_hash_empty (objects_hash_t * hash);
/** Searching **/
void *objects_hash_any_element (objects_hash_t * hash);
int objects_hash_contains_element (objects_hash_t * hash, void *element);
void *objects_hash_element (objects_hash_t * hash, void *element);
void **objects_hash_all_elements (objects_hash_t * hash);
/** Enumerating **/
objects_hash_enumerator_t objects_hash_enumerator (objects_hash_t * hash);
int objects_hash_enumerator_next_element (objects_hash_enumerator_t *enumerator, void **element);
/** Statistics **/
int objects_hash_is_empty (objects_hash_t * hash);
size_t objects_hash_count (objects_hash_t * hash);
size_t objects_hash_capacity (objects_hash_t * hash);
int objects_hash_check (objects_hash_t * hash);
/** Miscellaneous **/
size_t objects_hash_resize (objects_hash_t * hash, size_t new_capacity);
size_t objects_hash_rightsize (objects_hash_t * hash);
objects_hash_t * objects_hash_intersect_hash (objects_hash_t * hash, objects_hash_t * other_hash);
objects_hash_t * objects_hash_minus_hash (objects_hash_t * hash, objects_hash_t * other_hash);
objects_hash_t * objects_hash_union_hash (objects_hash_t * hash, objects_hash_t * other_hash);
#endif /* __hash_h_OBJECTS_INCLUDE */

252
Source/objects/list.h Normal file
View file

@ -0,0 +1,252 @@
/* A list for use with Libobjects.
* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Tue Sep 5 17:25:59 EDT 1995
* Updated: Sat Feb 10 15:37:41 EST 1996
* Serial: 96.02.10.01
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __list_h_OBJECTS_INCLUDE
#define __list_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
#include <objects/allocs.h>
#include <objects/callbacks.h>
#include <objects/hash.h>
#include <objects/array.h>
/**** Type, Constant, and Macro Definitions **********************************/
typedef struct _objects_list objects_list_t;
typedef struct _objects_list_node objects_list_node_t;
typedef struct _objects_list_enumerator objects_list_enumerator_t;
struct _objects_list_node
{
objects_list_t * list;
objects_list_node_t *next_in_list;
objects_list_node_t *prev_in_list;
void *element;
};
struct _objects_list
{
/* Container identifiers */
int magic;
size_t number;
char *name;
void *extra;
objects_callbacks_t extra_callbacks;
objects_allocs_t allocs;
/* Element callbacks */
objects_callbacks_t callbacks;
/* Internal counters */
size_t node_count;
size_t element_count;
/* Databanks */
objects_list_node_t *first_node;
objects_list_node_t *last_node;
};
struct _objects_list_enumerator
{
objects_list_t *list;
objects_list_node_t *node;
size_t forward;
};
/**** Function Prototypes ****************************************************/
/** Basics **/
#include <objects/list-basics.h>
#include <objects/list-callbacks.h>
/** Creating **/
objects_list_t * objects_list_alloc (void);
objects_list_t * objects_list_alloc_with_allocs (objects_allocs_t allocs);
objects_list_t * objects_list_with_allocs (objects_allocs_t allocs);
objects_list_t * objects_list_with_callbacks (objects_callbacks_t callbacks);
objects_list_t * objects_list_with_allocs_with_callbacks (objects_allocs_t allocs, objects_callbacks_t callbacks);
objects_list_t * objects_list_of_char_p (void);
objects_list_t * objects_list_of_void_p (void);
objects_list_t * objects_list_of_owned_void_p (void);
objects_list_t * objects_list_of_int (void);
objects_list_t * objects_list_of_int_p (void);
objects_list_t * objects_list_of_id (void);
/** Initializing **/
objects_list_t * objects_list_init (objects_list_t * list);
objects_list_t * objects_list_init_with_callbacks (objects_list_t * list, objects_callbacks_t callbacks);
/** Copying **/
objects_list_t * objects_list_copy (objects_list_t * old_list);
objects_list_t * objects_list_copy_with_allocs (objects_list_t * old_list, objects_allocs_t allocs);
/** Destroying **/
void objects_list_dealloc (objects_list_t * list);
/** Comparing **/
int objects_list_is_equal_to_list (objects_list_t * list, objects_list_t * other_list);
/** Concatenating **/
objects_list_t * objects_list_append_list (objects_list_t * base_list, objects_list_t * suffix_list);
objects_list_t * objects_list_prepend_list (objects_list_t * base_list, objects_list_t * prefix_list);
objects_list_t * objects_list_at_index_insert_list (objects_list_t * base_list, long int n, objects_list_t * infix_list);
/** Permuting **/
objects_list_t * objects_list_roll_to_nth_element (objects_list_t * list, long int n);
objects_list_t * objects_list_roll_to_element (objects_list_t * list, void *element);
objects_list_t * objects_list_roll_to_nth_occurrance_of_element (objects_list_t * list, long int n, void *element);
objects_list_t * objects_list_invert (objects_list_t * list);
objects_list_t * objects_list_swap_elements_at_indices (objects_list_t * list, long int m, long int n);
/** Adding **/
void *objects_list_append_element (objects_list_t * list, void *element);
void *objects_list_append_element_if_absent (objects_list_t * list, void *element);
void *objects_list_prepend_element (objects_list_t * list, void *element);
void *objects_list_prepend_element_if_absent (objects_list_t * list, void *element);
void *objects_list_at_index_insert_element (objects_list_t * list, long int n, void *element);
void *objects_list_at_index_insert_element_if_absent (objects_list_t * list, long int n, void *element);
void *objects_list_queue_push_element (objects_list_t * list, void *element);
void *objects_list_stack_push_element (objects_list_t * list, void *element);
/** Replacing **/
void objects_list_replace_nth_occurrance_of_element (objects_list_t * list, long int n, void *old_element, void *new_element);
void objects_list_replace_element (objects_list_t * list, void *old_element, void *new_element);
void objects_list_replace_nth_element (objects_list_t * list, long int n, void *new_element);
void objects_list_replace_first_element (objects_list_t * list, void *new_element);
void objects_list_replace_last_element (objects_list_t * list, void *new_element);
/** Removing **/
void objects_list_remove_nth_occurrence_of_element (objects_list_t * list, long int n, void *element);
void objects_list_remove_element (objects_list_t * list, void *element);
void objects_list_remove_nth_element (objects_list_t * list, long int n);
void objects_list_remove_first_element (objects_list_t * list);
void objects_list_remove_last_element (objects_list_t * list);
void objects_list_queue_pop_element (objects_list_t * list);
void objects_list_queue_pop_nth_element (objects_list_t * list, long int n);
void objects_list_stack_pop_element (objects_list_t * list);
void objects_list_stack_pop_nth_element (objects_list_t * list, long int n);
/** Emptying **/
void objects_list_empty (objects_list_t * list);
/** Searching **/
int objects_list_contains_element (objects_list_t * list, void *element);
void *objects_list_element (objects_list_t * list, void *element);
void *objects_list_nth_element (objects_list_t * list, long int n);
void *objects_list_first_element (objects_list_t * list);
void *objects_list_last_element (objects_list_t * list);
void **objects_list_all_elements (objects_list_t * list);
/** Enumerating **/
objects_list_enumerator_t objects_list_enumerator (objects_list_t * list);
objects_list_enumerator_t objects_list_forward_enumerator (objects_list_t * list);
objects_list_enumerator_t objects_list_reverse_enumerator (objects_list_t * list);
int objects_list_enumerator_next_element (objects_list_enumerator_t *enumerator, void **element);
/** Mapping **/
/* NO WARNING: The mapping function FCN need not be one-to-one on the
* elements of LIST. In fact, FCN may do whatever it likes. */
objects_list_t * objects_list_map_elements (objects_list_t * list, void *(*fcn) (void *, void *), void *user_data);
/** Statistics **/
int objects_list_is_empty (objects_list_t * list);
size_t objects_list_count (objects_list_t * list);
size_t objects_list_capacity (objects_list_t * list);
int objects_list_check (objects_list_t * list);
/** Miscellaneous **/
objects_hash_t *objects_hash_init_from_list (objects_hash_t *hash, objects_list_t * list);
#endif /* __list_h_OBJECTS_INCLUDE */

56
Source/objects/magic.h Normal file
View file

@ -0,0 +1,56 @@
/* Magic numbers for identifying Libobjects structures.
* Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Thu Mar 2 02:10:10 EST 1994
* Updated: Sat Feb 10 15:42:11 EST 1996
* Serial: 96.02.10.01
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __magic_h_OBJECTS_INCLUDE
#define __magic_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
/**** Type, Constant, and Macro Definitions **********************************/
/** Magic numbers **/
#define OBJECTS_MAGIC_ARRAY 0xfa138008 /* Thu Mar 2 02:28:50 EST 1994 */
#define OBJECTS_MAGIC_DATA 0xfa131971 /* Fri Nov 24 21:46:14 EST 1995 */
#define OBJECTS_MAGIC_HASH 0xfa133ee5 /* ??? ??? ?? ??:??:?? ??? 1993 */
#define OBJECTS_MAGIC_HEAP 0xfa13beef /* Tue Sep 5 17:21:34 EDT 1995 */
#define OBJECTS_MAGIC_LIST 0xfa13600d /* Tue Sep 5 17:23:50 EDT 1995 */
#define OBJECTS_MAGIC_MAP 0xfa13abba /* ??? ??? ?? ??:??:?? ??? 1993 */
/* WARNING: Don't use these. They are not guaranteed to remain in future
* editions of this file. They are here only as a cheap fix for an
* annoying little problem. */
/* FIXME: Get rid of these. See `x-basics.[ch].in'
* and `x-callbacks.[ch].in'. */
#define _OBJECTS_MAGIC_array OBJECTS_MAGIC_ARRAY
#define _OBJECTS_MAGIC_data OBJECTS_MAGIC_DATA
#define _OBJECTS_MAGIC_hash OBJECTS_MAGIC_HASH
#define _OBJECTS_MAGIC_heap OBJECTS_MAGIC_HEAP
#define _OBJECTS_MAGIC_list OBJECTS_MAGIC_LIST
#define _OBJECTS_MAGIC_map OBJECTS_MAGIC_MAP
#endif /* __magic_h_OBJECTS_INCLUDE */

330
Source/objects/map.h Normal file
View file

@ -0,0 +1,330 @@
/* A map table for use with Libobjects.
* Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: ??? ??? ?? ??:??:?? ??? 1993
* Updated: Sat Feb 10 13:36:59 EST 1996
* Serial: 96.02.10.01
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __map_h_OBJECTS_INCLUDE
#define __map_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
#include <objects/allocs.h>
#include <objects/callbacks.h>
#include <objects/hash.h>
/**** Type, Constant, and Macro Definitions **********************************/
typedef struct _objects_map objects_map_t;
typedef struct _objects_map_bucket objects_map_bucket_t;
typedef struct _objects_map_node objects_map_node_t;
typedef struct _objects_map_enumerator objects_map_enumerator_t;
/* Important structures... */
struct _objects_map_node
{
void *key;
void *value;
objects_map_bucket_t *bucket;
objects_map_t *map;
objects_map_node_t *next_in_bucket;
objects_map_node_t *prev_in_bucket;
objects_map_node_t *next_in_map;
objects_map_node_t *prev_in_map;
};
struct _objects_map_bucket
{
size_t node_count;
size_t element_count;
objects_map_node_t *first_node;
};
struct _objects_map
{
/* Container identifiers */
int magic;
size_t number;
char *name;
void *extra;
objects_callbacks_t extra_callbacks;
objects_allocs_t allocs;
objects_callbacks_t key_callbacks;
/* Management information */
objects_callbacks_t value_callbacks;
/* Internal counters */
size_t bucket_count;
size_t node_count;
size_t element_count;
/* Databanks */
objects_map_bucket_t *buckets;
objects_map_node_t *first_node;
};
struct _objects_map_enumerator
{
objects_map_t *map;
objects_map_node_t *node;
};
/**** Function Prototypes ****************************************************/
/** Basics **/
#include <objects/map-basics.h>
#include <objects/map-callbacks.h>
/** Altering capacity **/
size_t
objects_map_resize (objects_map_t * map, size_t new_capacity);
size_t
objects_map_rightsize (objects_map_t * map);
/** Creating **/
objects_map_t *
objects_map_alloc (void);
objects_map_t *
objects_map_alloc_with_allocs (objects_allocs_t allocs);
objects_map_t *
objects_map (void);
objects_map_t *
objects_map_with_allocs (objects_allocs_t allocs);
objects_map_t *
objects_map_with_allocs_with_callbacks (objects_allocs_t allocs,
objects_callbacks_t key_callbacks,
objects_callbacks_t value_callbacks);
objects_map_t *
objects_map_with_callbacks (objects_callbacks_t key_callbacks,
objects_callbacks_t value_callbacks);
objects_map_t *
objects_map_of_int (void);
objects_map_t *
objects_map_of_int_to_char_p (void);
objects_map_t *
objects_map_of_int_to_void_p (void);
objects_map_t *
objects_map_of_int_to_float (void);
objects_map_t *
objects_map_of_char_p (void);
objects_map_t *
objects_map_of_char_p_to_int (void);
objects_map_t *
objects_map_of_char_p_to_void_p (void);
objects_map_t *
objects_map_of_char_p_to_float (void);
objects_map_t *
objects_map_of_void_p (void);
objects_map_t *
objects_map_of_void_p_to_int (void);
objects_map_t *
objects_map_of_void_p_to_char_p (void);
objects_map_t *
objects_map_of_void_p_to_float (void);
objects_map_t *
objects_map_of_float (void);
objects_map_t *
objects_map_of_double (void);
/** Initializing **/
objects_map_t *
objects_map_init (objects_map_t * map);
objects_map_t *
objects_map_init_with_callbacks (objects_map_t * map,
objects_callbacks_t key_callbacks,
objects_callbacks_t value_callbacks);
/** Destroying **/
void
objects_map_dealloc (objects_map_t * map);
/** Gathering statistics on a mapionary **/
size_t
objects_map_pair_count (objects_map_t * map);
size_t
objects_map_capacity (objects_map_t * map);
int
objects_map_check_map (objects_map_t * map);
/** Finding elements in a mapionary **/
int
objects_map_contains_key (objects_map_t * map, void *key);
int
objects_map_key_and_value (objects_map_t * map,
void *key,
void **old_key,
void **value);
void *
objects_map_key (objects_map_t * map, void *key);
void *
objects_map_value (objects_map_t * map, void *key);
/** Enumerating the nodes and elements of a mapionary **/
objects_map_enumerator_t
objects_map_enumerator (objects_map_t * map);
int
objects_map_enumerator_next_key_and_value (objects_map_enumerator_t * enumerator,
void **key,
void **value);
int
objects_map_enumerator_next_key (objects_map_enumerator_t * enumerator,
void **key);
int
objects_map_enumerator_next_value (objects_map_enumerator_t * enumerator,
void **value);
/** Obtaining an array of the elements of a mapionary **/
void **
objects_map_all_keys_and_values (objects_map_t * map);
void **
objects_map_all_keys (objects_map_t * map);
void **
objects_map_all_values (objects_map_t * map);
/** Removing **/
void
objects_map_remove_key (objects_map_t * map, void *key);
void
objects_map_empty (objects_map_t * map);
/** Adding **/
void *
objects_map_at_key_put_value_known_absent (objects_map_t * map,
void *key,
void *value);
void *
objects_map_at_key_put_value (objects_map_t * map,
void *key,
void *value);
void *
objects_map_at_key_put_value_if_absent (objects_map_t * map,
void *key,
void *value);
/** Replacing **/
void
objects_map_replace_key (objects_map_t * map, void *key);
/** Comparing **/
int
objects_map_contains_map (objects_map_t * map1, objects_map_t * map2);
int
objects_map_is_equal_to_map (objects_map_t * map1, objects_map_t * map2);
/** Copying **/
objects_map_t *
objects_map_copy_with_allocs (objects_map_t * old_map, objects_allocs_t new_allocs);
objects_map_t *
objects_map_copy (objects_map_t * old_map);
/** Mapping **/
/* WARNING: The mapping function KFCN must be one-to-one on the keys
* of MAP. I.e., `objects_map_map_keys()' makes no provision for the
* possibility that KFCN maps two unequal keys of MAP to the same (or
* equal) keys. */
objects_map_t *
objects_map_map_keys (objects_map_t * map,
void *(*kfcn) (void *, void *),
void *user_data);
/* NO WARNING: The mapping function VFCN need not be one-to-one on
* (the equivalence classes of) values. */
objects_map_t *
objects_map_map_values (objects_map_t * map,
void *(*vfcn) (void *, void *),
void *user_data);
/** Miscellaneous **/
objects_map_t *
objects_map_intersect_map (objects_map_t * map, objects_map_t * other_map);
objects_map_t *
objects_map_minus_map (objects_map_t * map, objects_map_t * other_map);
objects_map_t *
objects_map_union_map (objects_map_t * map, objects_map_t * other_map);
objects_hash_t *
objects_hash_init_from_map_keys (objects_hash_t * hash, objects_map_t * map);
objects_hash_t *
objects_hash_init_from_map_values (objects_hash_t * hash, objects_map_t * map);
#endif /* __map_h_OBJECTS_INCLUDE */

51
Source/objects/minmax.h Normal file
View file

@ -0,0 +1,51 @@
/* GCC macros for minimum and maximum.
* Copyright (C) 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Sat Feb 10 21:13:04 EST 1996
* Updated: Sat Feb 10 21:13:04 EST 1996
* Serial: 96.02.10.01
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __minmax_h_OBJECTS_INCLUDE
#define __minmax_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
/**** Type, Constant, and Macro Definitions **********************************/
#ifdef MIN
#undef MIN
#endif /* !MIN */
#define MIN(X, Y) \
({ typeof (X) __x = (X), __y = (Y); \
(__x < __y) ? __x : __y; })
#ifdef MAX
#undef MAX
#endif /* !MAX */
#define MAX(X, Y) \
({ typeof (X) __x = (X), __y = (Y); \
(__x > __y) ? __x : __y; })
#endif /* __minmax_h_OBJECTS_INCLUDE */

49
Source/objects/number.h Normal file
View file

@ -0,0 +1,49 @@
/* Structure counters and functions for getting at them.
* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
*
* Author: Albin L. Jones <Albin.L.Jones@Dartmouth.EDU>
* Created: Sun Dec 3 00:28:01 EST 1995
* Updated: Sat Feb 10 15:51:02 EST 1996
* Serial: 96.02.10.01
*
* This file is part of the GNU Objective C Class Library.
*
* 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.
*
*/
#ifndef __number_h_OBJECTS_INCLUDE
#define __number_h_OBJECTS_INCLUDE 1
/**** Included Headers *******************************************************/
#include <stdlib.h>
/**** Type, Constant, and Macro Definitions **********************************/
extern size_t ___objects_number_allocated;
extern size_t ___objects_number_deallocated;
extern size_t ___objects_number_serial;
/**** Function Prototypes ****************************************************/
size_t _objects_number_allocated(void);
size_t _objects_number_deallocated(void);
size_t _objects_number_serial(void);
#endif /* __number_h_OBJECTS_INCLUDE */