querying local maps/lists in Java

Status
Not open for further replies.

rtstyk

Ars Scholae Palatinae
1,236
Does anyone know of an API that would allow me to do a query across local map or list objects? For example I'd like to be able to do something like:

Code:
select * from ProductsMap pm, CountriesMap cm, ThresholdsList tl where pm.countryId=cm.countryId and cm.continent.contains("America") and cm.populationSize>tl.4

In english this would translate into something like, all products in countries that contain the word America and have population size larger than the fourth element of the ThresholdList.

I hope this makes sense... :)
 

Faramir

Ars Legatus Legionis
36,356
Subscriptor
We don't have LINQ in java.

You have to do something like:
Code:
int minSize = thresholdList.get(4);
Set<Products> products = new HashSet<Products>();
for(Country country : CountriesMap)
{
  if(country.continent.contains("America") && country.populationSize > minSize)
  {
    for(Product product : ProductsMap)
    {
      if(product.country.equals(country))
      {
        products.add(product);
      }
    }
  }
}
 

ShuggyCoUk

Ars Legatus Legionis
10,387
Subscriptor++
Anyone know if someone's done something (c# idiomatic) like cqengine for c#.

I know I could use SQL Server Compact Edition plus LINQ but that adds considerable overhead in terms of concept translation (and nothing like the ability to add indices on the fly).

I looked about a while ago but didn't find anything, trying "cqengine c#" isn't being very forthcoming.
There articles like this one but that's not really an established project(http://i4o.codeplex.com/ looks pretty stalled).
 
Status
Not open for further replies.