/// <summary>
        /// Adds an item pair to the end of the List.
        /// This is an O(1) operation.
        /// </summary>
        /// <param name="key1">The A object to be added.</param>
        /// <param name="key2">The B object to be added.</param>
        public void Add(TKey1 key1, TKey2 key2)
        {
            ItemPair <TKey1, TKey2> node = new ItemPair <TKey1, TKey2>(key1, key2);

            lookupA.Add(key1, node);
            try
            {
                lookupB.Add(key2, node);
            }
            catch
            {
                lookupA.Remove(key1);
                throw;
            }
            list.Add(node);
        }
        /// <summary>
        /// Inserts a new ItemPair at the specified index.
        /// This method needs a full index rebuild and is an O(n) operation, where n is Count.
        /// </summary>
        /// <param name="index">The index to insert the item at.</param>
        /// <param name="item">The ItemPair to insert.</param>
        public void Insert(int index, ItemPair <TKey1, TKey2> item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            lookupA.Add(item.A, item);
            try
            {
                lookupB.Add(item.B, item);
            }
            catch
            {
                lookupA.Remove(item.A);
                throw;
            }
            list.Insert(index, item);
        }
        /// <summary>
        /// Removes the ItemPair at the specified index.
        /// This method needs a full index rebuild and is an O(n) operation, where n is Count.
        /// </summary>
        /// <param name="index">The index to remove the item.</param>
        public void RemoveAt(int index)
        {
            try
            {
                ItemPair <TKey1, TKey2> node = list[index];
                if (!lookupA.Remove(node.A))
                {
                    throw new KeyNotFoundException();
                }

                if (!lookupB.Remove(node.B))
                {
                    throw new KeyNotFoundException();
                }
            }
            catch
            {
                Clear();
                throw;
            }
        }
 /// <summary>
 /// Obtains the index of the specified ItemPair.
 /// This is an O(1) operation.
 /// </summary>
 /// <param name="item">The ItemPair to search for.</param>
 /// <returns>The index of the ItemPair if found in the list; otherwise, -1.</returns>
 public int IndexOf(ItemPair <TKey1, TKey2> item)
 {
     return(list.IndexOf(item));
 }