private static void AddKeyValue(Hashtable keyTable, String key, XPathNavigator value, bool checkDuplicates) {
ArrayList list = (ArrayList)keyTable[key];
if (list == null) {
list = new ArrayList();
keyTable.Add(key, list);
} else {
Debug.Assert(
value.ComparePosition((XPathNavigator) list[list.Count - 1]) != XmlNodeOrder.Before,
"The way we traversing nodes should garantees node-order"
);
if (checkDuplicates) {
// it's posible that this value already was assosiated with current node
// but if this happened the node is last in the list of values.
if (value.ComparePosition((XPathNavigator) list[list.Count - 1]) == XmlNodeOrder.Same) {
return;
}
} else {
Debug.Assert(
value.ComparePosition((XPathNavigator) list[list.Count - 1]) != XmlNodeOrder.Same,
"checkDuplicates == false : We can't have duplicates"
);
}
}
list.Add(value.Clone());
}