Program Listing for File ds.h

Return to documentation for file (rcsw/ds/ds.h)

#pragma once

/*******************************************************************************
 * Includes
 ******************************************************************************/
#include "rcsw/rcsw.h"
#include "rcsw/common/flags.h"

#include "rcsw/ds/allocm.h"

/*******************************************************************************
 * Constant Definitions
 ******************************************************************************/
enum ds_tag {
  ekRCSW_DS_DARRAY,
  ekRCSW_DS_LLIST,
  ekRCSW_DS_RBUFFER,
};

#define RCSW_DS_SORTED (1 << (RCSW_MODFLAGS_START + 0))

#define RCSW_DS_ORDERED (1 << (RCSW_MODFLAGS_START + 1))

#define RCSW_DS_HASHMAP_LINPROB (1 << (RCSW_MODFLAGS_START + 2))

#define RCSW_DS_RBUFFER_AS_FIFO  (1 << (RCSW_MODFLAGS_START + 3))

#define RCSW_DS_LLIST_DB_DISOWN  (1 << (RCSW_MODFLAGS_START + 4))

#define RCSW_DS_LLIST_DB_PTR  (1 << (RCSW_MODFLAGS_START + 5))

#define RCSW_DS_BSTREE_RB  (1 << (RCSW_MODFLAGS_START + 6))

#define RCSW_DS_BSTREE_INT  (1 << (RCSW_MODFLAGS_START + 7))

#define RCSW_DS_BSTREE_OS  (1 << (RCSW_MODFLAGS_START + 8))

#define RCSW_DS_BINHEAP_MIN  (1 << (RCSW_MODFLAGS_START + 9))

#define RCSW_DS_EXTFLAGS_START 10

/*******************************************************************************
 * RCSW Private Functions
 ******************************************************************************/
BEGIN_C_DECLS

RCSW_LOCAL status_t ds_elt_swap(void *elt1, void *elt2, size_t elt_size);

static inline size_t ds_meta_space(size_t max_elts) {
  return sizeof(struct allocm_entry) * max_elts;
}

static inline size_t ds_elt_space_simple(size_t max_elts, size_t elt_size) {
  return max_elts * elt_size;
}

static inline size_t ds_elt_space_with_meta(size_t max_elts, size_t elt_size) {
  return ds_meta_space(max_elts) + ds_elt_space_simple(max_elts, elt_size);
}

/*******************************************************************************
 * API Functions
 ******************************************************************************/
RCSW_API status_t ds_elt_clear(void *elt, size_t elt_size);

RCSW_API status_t ds_elt_copy(void *elt1, const void *elt2, size_t elt_size);

END_C_DECLS