Bidirectional map is associative data structure where keys and values can switch their roles.
Questions tagged [bimap]
85 questions
3
votes
1 answer
Is there a weak/soft bidirectional Map in Java?
I would like a "symbol alphabet" to have a bi-directional map with weak/soft references. Something like an Apache's Common BidiMap (or Guava's BiMap) with a WeakMap-like interface.
A solution would be to use BiMap,V> and once in a…

miltos
- 89
- 1
- 6
2
votes
3 answers
Issue with Guava's BiMap and LinkedHashMap
Is it possible in Guava,
To conduct a reverse lookup in BiMap for key and multiple values? Precisely, I have key and corresponding multiple values, I want to get key from a value.
To store multiple values in LinkedHashMap? Precisely, I want to…

Arpssss
- 3,850
- 6
- 36
- 80
2
votes
0 answers
inserting into boost bimap with many-to-many relationship
I'd like create a data structure that will describe a relation between posts and tags. Each post can have multiple tags and a tag can be applied to many posts.
Each post and tag can be uniquely identified by a key (let's say int).
I want to be able…

thesamet
- 6,382
- 2
- 31
- 42
2
votes
1 answer
How to traverse a map by value
Say there is a map: typedef map MyMap;
I'd like to traverse it by the string, for example:
3 -> a
1 -> b
7 -> b
2 -> c
One way is to sort this map by its value. But I'm afraid this will have impact to find() efficiency (is it…

Deqing
- 14,098
- 15
- 84
- 131
2
votes
4 answers
Is there a data structure with 2 indizes / a key-key data-structure?
Is there a data structure in Java (java util, guava...) that allows me to store "key value" pairs that can also be interpreted as value-key?
Example:
Datastructure d = new Datastructure();
d.add(1, "foo");
d.add(21 "bar");
d.add(33…

hardfork
- 2,470
- 1
- 23
- 43
2
votes
1 answer
Is boost::bimap overkill for injective functions?
Let T_1 and T_2 be two types and f: Dom(T_1) -> Dom(T_2) be an injective function which is not a bijection; and for the sake of discussion suppose I get a representation of f as disparate pairs rather than code for computing it. Now, I need to be…

einpoklum
- 118,144
- 57
- 340
- 684
2
votes
1 answer
Synchronization for inverse view of synchronized BiMap
The Maps.synchronizedBiMap() method states that
it is imperative that the user manually synchronize on the returned map
when accessing any of its collection views.
Does this include the inverse() view of the BiMap? For example, if the variables…

S1lentSt0rm
- 1,989
- 2
- 17
- 28
2
votes
0 answers
Efficient search of bimap
I have a bimap of length approx. 280000, and I am searching this bimap for atleast 18 million times for a value. The minimal example of the bimap that I have with me is given below;
#include
#include
#include
#include…

AwaitedOne
- 992
- 3
- 19
- 42
2
votes
1 answer
Serialize BiMap with xStream
I`d like to serialize a BiMap with xStream. Since I dont like the auto generated code by xStream for a BiMap, I thought it might be a good Idea to convert a BiMap into a HashMap and serialize just the HashMap and when deserializing it, I just read…

crusam
- 6,140
- 6
- 40
- 68
2
votes
2 answers
Problems that we use a BiMap to solve
I'm reviewing the capabilities of Googles Guava API and I ran into a data structure that I haven't seen used in my 'real world programming' experience, namely, the BiMap. Is the only benefit of this construct the ability to quickly retrieve a key,…

Amir Afghani
- 37,814
- 16
- 84
- 124
2
votes
3 answers
which data structure should be used multimap, boost::bimap, multiset or any other
In my program there are some users and their clients.
I have the list of users and their associated clients.
Example
U1 -> c1, c2, c3, c5, c8, c10, c12
U2 -> c3, c5, c13, c8, c12, c14
U3 -> C2, C5, c8, c11, c12, c14
..
...
....
.....
and many…

user1841046
- 93
- 10
2
votes
2 answers
Boost: Accessing bimap using operator[]
In the following code:
typedef bimap< set_of< std::string >, list_of< int > > bm_type;
bm_type bm;
bm.left["one"] = 1; // "one" -> 1
bm.left["one"] = 2; // replaced: "one" -> 2
bm.right[2] = "two"; // Compile error
How can I get rid of the compile…

B Faley
- 17,120
- 43
- 133
- 223
1
vote
1 answer
find() problems with boost bimap
I have the following code:
wxString getColorName(const wxColour& color)
{
typedef ColorComboBox::ColorMap::right_const_iterator ConstColorIterator;
ColorComboBox::ColorMap colorMap = ColorComboBox::getDefaultChoices();
ConstColorIterator…

Eva
- 4,397
- 5
- 43
- 65
1
vote
3 answers
Boost bimap can't convert const CompatibleKey to Key&
It is one of the first times I am using boost and I am getting an error saying
BaseKey boost::bimaps::container_adaptor::detail::key_to_base_identity::operator ()(Key &) const': cannot convert argument 1 from 'const CompatibleKey'…

lnlyprog
- 23
- 5
1
vote
1 answer
Guava biMap for bi directional map, but do we have any thread safe bi directional map?
Guava biMap for bi directional map, but do we have any thread safe bi directional map ?

Vinay S Jain
- 63
- 7