voronoi icon indicating copy to clipboard operation
voronoi copied to clipboard

Access to the site by its index

Open Mikez2015 opened this issue 3 years ago • 1 comments

Now, to get access to a separate site by its index, you need to either make a separate array sorted by site indexes, or use a chart search. Maybe there are other ways that I can't see?

Mikez2015 avatar Sep 08 '21 01:09 Mikez2015

I create an array where each entry is the index of the site with that site->index. A reverse lookup to "restore order".

	uint32_t* restore_order = new uint32_t[my_diagram.numsites];
	std::memset(restore_order, 0, my_diagram.numsites * sizeof(uint32_t));
	{
		const jcv_site* sites = jcv_diagram_get_sites(&my_diagram);
		for (int i = 0; i < my_diagram.numsites; ++i)
		{
			const jcv_site* site = sites + i;
			restore_order[site->index] = i;
		}
	}

fatlimey avatar Apr 18 '23 19:04 fatlimey