Algorithm-QuadTree-XS

 view release on metacpan or  search on metacpan

XS.xs  view on Meta::CPAN


typedef struct QuadTreeNode QuadTreeNode;
typedef struct QuadTreeRootNode QuadTreeRootNode;
typedef struct DynArr DynArr;
typedef struct Shape Shape;

typedef enum ShapeType ShapeType;

struct QuadTreeNode {
	QuadTreeNode *children;
	QuadTreeNode *parent;
	DynArr *values;
	double xmin, ymin, xmax, ymax;
	bool has_objects;
};

struct QuadTreeRootNode {
	QuadTreeNode *node;
	HV *backref;
};

XS.xs  view on Meta::CPAN

	arr->ptr[arr->count] = ptr;
	arr->count += 1;
}

void push_array_SV(DynArr *arr, SV *ptr)
{
	push_array(arr, ptr);
	SvREFCNT_inc(ptr);
}

QuadTreeNode* create_nodes(int count, QuadTreeNode *parent)
{
	QuadTreeNode *node = malloc(count * sizeof *node);

	int i;
	for (i = 0; i < count; ++i) {
		node[i].values = NULL;
		node[i].children = NULL;
		node[i].parent = parent;
		node[i].has_objects = false;
	}

	return node;
}

/* NOTE: does not actually free the node, but frees its children nodes */
void destroy_node(QuadTreeNode *node)
{
	if (node->values != NULL) {

XS.xs  view on Meta::CPAN

void clear_has_objects (QuadTreeNode *node)
{
	if (node->values == NULL) {
		int i;
		for (i = 0; i < CHILDREN_PER_NODE; ++i) {
			if (node->children[i].has_objects) return;
		}
	}

	node->has_objects = false;
	if (node->parent != NULL) {
		clear_has_objects(node->parent);
	}
}

QuadTreeRootNode* create_root()
{
	QuadTreeRootNode *root = malloc(sizeof *root);
	root->node = create_nodes(1, NULL);
	root->backref = newHV();

	return root;

ppport.h  view on Meta::CPAN

op_linklist|5.013006|5.013006|
op_lvalue|5.013007|5.013007|x
op_lvalue_flags|||ciu
OP_LVALUE_NO_CROAK|5.015001||Viu
OpMAYBESIB_set|5.021011|5.003007|p
opmethod_stash|5.021007||Viu
OpMORESIB_set|5.021011|5.003007|p
OP_NAME|5.007003|5.007003|
op_null|5.007002|5.007002|
OPpALLOW_FAKE|5.015006||Viu
op_parent|5.025001|5.025001|n
OPpARG1_MASK|5.021004||Viu
OPpARG2_MASK|5.021004||Viu
OPpARG3_MASK|5.021004||Viu
OPpARG4_MASK|5.021004||Viu
OPpARGELEM_AV|5.025004||Viu
OPpARGELEM_HV|5.025004||Viu
OPpARGELEM_MASK|5.025004||Viu
OPpARGELEM_SV|5.025004||Viu
OPpASSIGN_BACKWARDS|5.003007||Viu
OPpASSIGN_COMMON_AGG|5.023002||Viu

ppport.h  view on Meta::CPAN


#ifndef OpSIBLING
#  define OpSIBLING(o)                   (0 + (o)->op_sibling)
#endif

#ifndef OpMORESIB_set
#  define OpMORESIB_set(o, sib)          ((o)->op_sibling = (sib))
#endif

#ifndef OpLASTSIB_set
#  define OpLASTSIB_set(o, parent)       ((o)->op_sibling = NULL)
#endif

#ifndef OpMAYBESIB_set
#  define OpMAYBESIB_set(o, sib, parent) ((o)->op_sibling = (sib))
#endif

#ifndef HEf_SVKEY
#  define HEf_SVKEY                      -2
#endif

#if defined(DEBUGGING) && !defined(__COVERITY__)
#ifndef __ASSERT_
#  define __ASSERT_(statement)           assert(statement),
#endif



( run in 0.239 second using v1.01-cache-2.11-cpan-4d50c553e7e )