Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the lightest collection for store these values? [closed]

Tags:

c#

.net

I have many objects (such as 10.000, more or less). Every object has3 values :

  1. Index (decimal, such as 0,0 <= X <= 100.000,9);
  2. A Latitude value;
  3. A Longitude value;

and I need to perform some search due to the Index value. Which will be the light approch to this? List<MyObject>? I know there are hashtable, but only for 2 values...

I read these values from a .csv file and I'll store it on application. WebForm, .NET 4.5.

like image 516
markzzz Avatar asked Nov 22 '25 01:11

markzzz


1 Answers

The very lightest approach in terms of memory use is to put these into a struct, and hold them in an array of such structs. From what you say, you can't really pack data any tighter than that: two doubles and a decimal will occupy 32 bytes per entry, and the array of structs does not add any per-item overhead on top of this.

Having said that, this will slow down your coding and might save too little to matter in practice.

like image 182
Roman Starkov Avatar answered Nov 23 '25 14:11

Roman Starkov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!