What data structure to use?

I need a data structure with the following properties:

  • Access to items should be very fast.
  • Elements that are not added should not accept memory (as ideal, the size of the empty structure next to zero)
  • Each element has two integer coordinates (x, y) (access to elements only by them)
  • The maximum number of elements known at the time of creation (more than 10 ^ 3)
  • An element contains multiple floating point values.

It would be nice if you also directed the implementation of this structure to C or C ++.

+5
source share
4 answers

Check this out - you can change the item type to floatif it does all that you need.

C

++ Boost.uBLAS - sparse_matrix .

+3

?

+7

X Y , . 10000 40K 32- .

+1

 

typdef ElementAccessor std::pair<int, int>;

struct Element
{
  float f1;
  float f2;
  //etc.

};

std::map< ElementAccessor, Element > myElementMap;

. ElementAccessor x, y. , , , .

http://www.cplusplus.com/reference/std/utility/pair/ http://www.cplusplus.com/reference/stl/map/find/

edit: . - ElementAccessor, - Element. , templating int, int.

+1

All Articles