in reply to How to improve this data structure?
Are the region numbers sequential, or discontiguous?
If sequential:
my @StatsArray; push @{$StatsArray[$RegionNum]}, { AR => $AR[$RegionNum], BCR => $BCR[$RegionNum], };
If sparse, this:
my %Stats; push @{$Stats{$RegionNum}}, { ... };
Then you could do this:
my @sorted = sort { $a->{AR} <=> $b->{AR} } @{ $StatsArray[$RegionNum] + };
...for example.
It might be that you're getting to the point where a database would scale better though. Another approach might be to just build a binary tree, maintaining nodes in sorted order. This allows for relatively inexpensive inserts and searches. But it does sound like you might need the scalability of a DB approach.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to improve this data structure?
by jhourcle (Prior) on May 21, 2013 at 14:56 UTC | |
|
Re^2: How to improve this data structure?
by fiddler42 (Beadle) on May 21, 2013 at 21:11 UTC | |
by davido (Cardinal) on May 21, 2013 at 21:25 UTC | |
by fiddler42 (Beadle) on May 21, 2013 at 22:10 UTC | |
|
Re^2: How to improve this data structure?
by Anonymous Monk on May 21, 2013 at 21:06 UTC |