76 assert((seq &
SEQ_MASK) == seq &&
"sequence ID overflow");
83 if (
agroot(g)->desc.has_attrs)
118 if (
agroot(g)->desc.has_attrs)
130 if (n ==
NULL && cflag) {
229 new_id = *(uint64_t *) arg;
231 assert(
key !=
NULL &&
"node being renamed does not exist");
269 if (n ==
NULL && cflag) {
350 assert((seq &
SEQ_MASK) == seq &&
"sequence ID overflow");
362 uint64_t seq =
AGSEQ(n) + 1;
363 assert((seq &
SEQ_MASK) == seq &&
"sequence ID overflow");
374 assert(
AGSEQ(fst) != 0 &&
"sequence ID overflow");
407 assert(self !=
NULL);
413 assert(self !=
NULL);
417 static const double OCCUPANCY_THRESHOLD = 0.7;
428 if (!grow && self->
size / self->
capacity > OCCUPANCY_THRESHOLD) {
440 for (
size_t i = 0; i < self->
capacity; ++i) {
461 for (
size_t i = 0; i < self->
capacity; ++i) {
462 const size_t candidate = (index + i) % self->
capacity;
476 assert(self !=
NULL);
480 if (self->
size == 0) {
486 for (
size_t i = 0; i < self->
capacity; ++i) {
487 const size_t candidate = (index + i) % self->
capacity;
500 return self->
slots[candidate];
508 assert(self !=
NULL);
512 if (self->
size == 0) {
518 for (
size_t i = 0; i < self->
capacity; ++i) {
519 const size_t candidate = (index + i) % self->
capacity;
532 assert(self->
size > 0);
541 assert(self !=
NULL);
546 assert(self !=
NULL);
549 free((*self)->slots);
Memory allocation wrappers that exit on failure.
static void * gv_calloc(size_t nmemb, size_t size)
static void * gv_alloc(size_t size)
int agapply(Agraph_t *g, Agobj_t *obj, agobjfn_t fn, void *arg, int preorder)
CDT_API int dtsize(Dt_t *)
CDT_API void * dtrenew(Dt_t *, void *)
void agfreeid(Agraph_t *g, int objtype, IDTYPE id)
void agrecclose(Agobj_t *obj)
int agmapnametoid(Agraph_t *g, int objtype, char *str, IDTYPE *result, bool createflag)
void agdeledgeimage(Agraph_t *g, Agedge_t *edge, void *ignored)
int agallocid(Agraph_t *g, int objtype, IDTYPE request)
uint64_t agnextseq(Agraph_t *g, int objtype)
void agregister(Agraph_t *g, int objtype, void *obj)
static Agnode_t * agfindnode_by_name(Agraph_t *g, char *name)
static Agsubnode_t *const TOMBSTONE
a sentinel, marking a set slot from which an element has been deleted
static int agsubnodeseqcmpf(void *arg0, void *arg1)
Agsubnode_t * node_set_find(node_set_t *self, IDTYPE key)
Agnode_t * agfindnode_by_id(Agraph_t *g, IDTYPE id)
void agdelnodeimage(Agraph_t *g, Agnode_t *n, void *ignored)
Dtdisc_t Ag_subnode_seq_disc
static size_t node_set_index(const node_set_t *self, IDTYPE id)
static void installnode(Agraph_t *g, Agnode_t *n)
static void installnodetoroot(Agraph_t *g, Agnode_t *n)
static void initnode(Agraph_t *g, Agnode_t *n)
static void dict_relabel(Agraph_t *ignored, Agnode_t *n, void *arg)
void node_set_free(node_set_t **self)
static void agnoderenew(Agraph_t *g, Agnode_t *n, void *ignored)
size_t node_set_size(const node_set_t *self)
static bool agsubnodeideq(const Agsubnode_t *sn0, IDTYPE id)
static Agnode_t * newnode(Agraph_t *g, IDTYPE id, uint64_t seq)
node_set_t * node_set_new(void)
void node_set_add(node_set_t *self, Agsubnode_t *item)
void node_set_remove(node_set_t *self, IDTYPE item)
static void free_subnode(void *subnode)
static void agnodesetfinger(Agraph_t *g, Agnode_t *n, void *ignored)
void * agalloc(Agraph_t *g, size_t size)
void agfree(Agraph_t *g, void *ptr)
void agnodeattr_init(Agraph_t *g, Agnode_t *n)
void agnodeattr_delete(Agnode_t *n)
void agmethod_delete(Agraph_t *g, void *obj)
void agmethod_init(Agraph_t *g, void *obj)
int agdeledge(Agraph_t *g, Agedge_t *arg_e)
Agedge_t * agnxtedge(Agraph_t *g, Agedge_t *e, Agnode_t *n)
Agedge_t * agfstedge(Agraph_t *g, Agnode_t *n)
void(* agobjfn_t)(Agraph_t *g, Agobj_t *obj, void *arg)
Agnode_t * agnode(Agraph_t *g, char *name, int cflag)
int agnodebefore(Agnode_t *fst, Agnode_t *snd)
Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Agnode_t * agprvnode(Agraph_t *g, Agnode_t *n)
Agnode_t * agfstnode(Agraph_t *g)
Agnode_t * agsubnode(Agraph_t *g, Agnode_t *n0, int cflag)
Agnode_t * agidnode(Agraph_t *g, IDTYPE id, int cflag)
Agnode_t * aglstnode(Agraph_t *g)
int agrelabel_node(Agnode_t *n, char *newname)
int agdelnode(Agraph_t *g, Agnode_t *n)
removes a node from a graph or subgraph.
Agsubnode_t * agsubrep(Agraph_t *g, Agnode_t *n)
Agraph_t * agraphof(void *obj)
#define AGID(obj)
returns the unique integer ID associated with the object
uint64_t IDTYPE
unique per main graph ID
#define AGTYPE(obj)
returns AGRAPH, AGNODE, or AGEDGE depending on the type of the object
Agraph_t * agroot(void *obj)
void * agbindrec(void *obj, const char *name, unsigned int recsize, int move_to_front)
attaches a new record of the given size to the object
Agraph_t * agparent(Agraph_t *g)
unordered set of Agsubnode_t *
string attribute container
a generic header of Agraph_s, Agnode_s and Agedge_s
Agtag_t tag
access with AGTAG
struct graphviz_node_set * n_id
the node set indexed by ID
Dict_t * n_seq
the node set in sequence
Agclos_t * clos
shared resources
size_t capacity
size of slots
size_t size
number of elements in the set
Agsubnode_t ** slots
backing store for elements