You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
877 B
C

#pragma once
#include <stdbool.h>
struct collection;
struct collection_vtable
{
void (*get_item)( struct collection it, int i, void* item );
void (*set_item)( struct collection it, int i, void* item );
int (*size)( struct collection it );
void (*resize)( struct collection it, int new_size );
void (*free)( struct collection it );
};
struct item_type_vtable
{
int size;
void (*free)( struct collection it, void* item );
int (*compare)( struct collection it, void* a, void* b );
/*
Should return:
-1 when a < b
1 when a > b
0 when a = b
Same as strcmp
*/
};
struct collection
{
void* ptr;
struct collection_vtable* vtable;
struct item_type_vtable* itable;
};
void collection_free( struct collection c );
bool collection_add_unique( struct collection c, void* item );
void collection_copy( struct collection src, struct collection dst );