74 assert((seq &
SEQ_MASK) == seq &&
"sequence ID overflow");
81 if (
agroot(g)->desc.has_attrs)
116 if (
agroot(g)->desc.has_attrs)
128 if (n ==
NULL && cflag) {
227 new_id = *(uint64_t *) arg;
229 assert(key !=
NULL &&
"node being renamed does not exist");
267 if (n ==
NULL && cflag) {
348 assert((seq &
SEQ_MASK) == seq &&
"sequence ID overflow");
360 uint64_t seq =
AGSEQ(n) + 1;
361 assert((seq &
SEQ_MASK) == seq &&
"sequence ID overflow");
372 assert(
AGSEQ(fst) != 0 &&
"sequence ID overflow");
409 assert(self !=
NULL);
426 assert(self !=
NULL);
430 static const size_t OCCUPANCY_THRESHOLD_PERCENT = 70;
434 const bool grow = 100 * self->
size >= OCCUPANCY_THRESHOLD_PERCENT * capacity;
437 const size_t new_c = capacity == 0 ? 10 : self->
capacity_exp + 1;
444 for (
size_t i = 0; i < capacity; ++i) {
464 self->
min =
item->node->base.tag.id;
466 if (
item->node->base.tag.id > self->
max) {
467 self->
max =
item->node->base.tag.id;
471 assert(capacity > self->
size);
475 for (
size_t i = 0; i < capacity; ++i) {
476 const size_t candidate = (
hash + i) % capacity;
490 assert(self !=
NULL);
496 if (key > self->
max) {
503 for (
size_t i = 0; i < capacity; ++i) {
504 const size_t candidate = (
hash + i) % capacity;
517 return self->
slots[candidate];
525 assert(self !=
NULL);
530 for (
size_t i = 0; i < capacity; ++i) {
531 const size_t candidate = (
hash + i) % capacity;
544 assert(self->
size > 0);
553 assert(self !=
NULL);
558 assert(self !=
NULL);
561 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)
static size_t node_set_hash(IDTYPE id)
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 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 size_t node_set_get_capacity(const node_set_t *self)
static void free_subnode(void *subnode)
static void agnodesetfinger(Agraph_t *g, Agnode_t *n, void *ignored)
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
Agraph_t * root
subgraphs - ancestors
Dict_t * n_seq
the node set in sequence
Agclos_t * clos
shared resources
size_t capacity_exp
logâ‚‚ size of slots
size_t size
number of elements in the set
Agsubnode_t ** slots
backing store for elements