bidirectional map

bioinfornatics bioinfornatics at fedoraproject.org
Mon Nov 11 17:14:46 PST 2013


Dear,
I am looking for a bidirectional map i.e 
http://en.wikipedia.org/wiki/Bidirectional_map

My seach into D documentation seem to said to me that this 
structure is not implemented.

Something like (for primary idea):


struct BidirectionalMap(T,U){
     private:
         T[U] _forwardHash;
         U[T] _reverseHash;

     public:

         @safe
         void opIndeyAssign( T k, U v){ // pure?
             _forwardHash[k] = v;
             _reverseHash[v] = k;
         }


         @property
         BidirectionalMap!(T,U) dup(){
             return BidirectionalMap!(T,U)( this );
         }
}


More information about the Digitalmars-d-learn mailing list