w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Data structure for partial multi-keys mapping?

if there exist a maximum(M) value for each part of the keys, you can create a single keyed tree by interpreting the keys as numbers written in base M (or in mixed base)

  • i assume wildcards only appear at one index and all furter are wildcards, this way (x,*,*,*) will be a query for (x*M^3,(x+1)*M^3-1)

for strings:

  • you can use a separating character and token paste the keys (using |:

('ax','bc','a','x') -> 'ax|bc|a|x'

the separator should not appear in the input strings(it may appear, but in that case it may interfere with accessing the asked results)

but...if your situation is difficult you can use objects as keys, in java i would create a class for the key, and define a compare oparator between them

for examples i would quote: Best way to compare objects by multiple fields?





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.