Sign in to follow this  
Instigator

Searching Algorithm on Matrix Type Data

Recommended Posts

Instigator    150

I would like to implement an efficient algorithm to search data as part of the following format.

 

|X|Y|100 character length string|

 

All columns are non-unique. Which means you can have

 

|5.5|23.4|SOME TEXT|

|10.1|12.2|SOME TEXT|

|10.1|10.1|MORE TEXT|

 

 

An example of a query would be :

 

- FindText("SOME*") /*Returns all rows with this text */

- FindX(10.1)

- FindY(10.1)

.

.

 

Will a simple array suffice or is their an algorithm more efficient I should  read about? 

Edited by Instigator

Share this post


Link to post
Share on other sites
alvaro    21247

You can keep the data in an array and then have auxiliary data structures to be used as indices, which would map values of a column to indexes to the main array. If you are using C++, std::unordered_multimap is a good way to do this.

 

If you are never going to remove data, this is really simple.

Edited by Álvaro

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this