示例#1
0
 /// <summary>Constructs a bijection out of two existing dictionaries.</summary>
 /// <remarks>
 /// To save time, the constructor does not verify that the two dictionaries
 /// are a proper bijection; instead it works "on the honor system", and only
 /// checks to ensure that the two dictionaries have the same <c>Count</c>.
 /// The two dictionaries must already be a bijection (one-to-one maps into
 /// each other) and should not be modified after they are attached to this
 /// object. Of course, you can supply two empty dictionaries of any type.
 /// </remarks>
 public Bijection(IDictionary <K1, K2> cur, IDictionary <K2, K1> inv)
 {
     _map     = cur;
     _inverse = new Bijection <K2, K1>(inv, this);
     if (cur.Count != inv.Count)
     {
         throw new InvalidStateException("Bijection(): invalid input, dictionaries have different lengths");
     }
     if (cur.IsReadOnly != inv.IsReadOnly)
     {
         throw new ArgumentException("Bijection(): IsReadOnly mismatch");
     }
 }
示例#2
0
 protected Bijection(IDictionary <K1, K2> cur, Bijection <K2, K1> other)
 {
     _map     = cur;
     _inverse = other;
 }