/// <summary> /// Constructs a XPathNode. Later, the idxSibling and value fields may be fixed up. /// </summary> public void Create(XPathNodeInfoAtom info, XPathNodeType xptyp, int idxParent) { Debug.Assert(info != null && idxParent <= UInt16.MaxValue); this.info = info; this.props = (uint)xptyp; this.idxParent = (ushort)idxParent; }
/// <summary> /// Initialize an existing shared information atom. This method should only be used by the XNodeInfoTable. /// </summary> public void Init(string localName, string namespaceUri, string prefix, string baseUri, XPathNode[] pageParent, XPathNode[] pageSibling, XPathNode[] pageSimilar, XPathDocument doc, int lineNumBase, int linePosBase) { Debug.Assert(localName != null && namespaceUri != null && prefix != null && doc != null); this.localName = localName; this.namespaceUri = namespaceUri; this.prefix = prefix; this.baseUri = baseUri; this.pageParent = pageParent; this.pageSibling = pageSibling; this.pageSimilar = pageSimilar; this.doc = doc; this.lineNumBase = lineNumBase; this.linePosBase = linePosBase; this.next = null; this.pageInfo = null; this.hashCode = 0; this.localNameHash = 0; for (int i = 0; i < this.localName.Length; i++) { this.localNameHash += (this.localNameHash << 7) ^ this.localName[i]; } }
/// <summary> /// Return true if this InfoAtom has the same values as another InfoAtom. /// </summary> public override bool Equals(object other) { XPathNodeInfoAtom that = other as XPathNodeInfoAtom; Debug.Assert(that != null); Debug.Assert((object)this.doc == (object)that.doc); Debug.Assert(this.pageInfo == null); // Assume that name parts are atomized if (this.GetHashCode() == that.GetHashCode()) { if ((object)this.localName == (object)that.localName && (object)this.pageSibling == (object)that.pageSibling && (object)this.namespaceUri == (object)that.namespaceUri && (object)this.pageParent == (object)that.pageParent && (object)this.pageSimilar == (object)that.pageSimilar && (object)this.prefix == (object)that.prefix && (object)this.baseUri == (object)that.baseUri && this.lineNumBase == that.lineNumBase && this.linePosBase == that.linePosBase) { return(true); } } return(false); }
private void AddInfo(XPathNodeInfoAtom info) { int index = info.GetHashCode() & (this.hashTable.Length - 1); info.Next = this.hashTable[index]; this.hashTable[index] = info; this.sizeTable++; }
/// <summary> /// Create a new XNodeInfoAtom and ensure it is atomized in the table. /// </summary> public XPathNodeInfoAtom Create(string localName, string namespaceUri, string prefix, string baseUri, XPathNode[] pageParent, XPathNode[] pageSibling, XPathNode[] pageSimilar, XPathDocument doc, int lineNumBase, int linePosBase) { XPathNodeInfoAtom info; // If this.infoCached already exists, then reuse it; else create new InfoAtom if (this.infoCached == null) { info = new XPathNodeInfoAtom(localName, namespaceUri, prefix, baseUri, pageParent, pageSibling, pageSimilar, doc, lineNumBase, linePosBase); } else { info = this.infoCached; this.infoCached = info.Next; info.Init(localName, namespaceUri, prefix, baseUri, pageParent, pageSibling, pageSimilar, doc, lineNumBase, linePosBase); } return(Atomize(info)); }
/// <summary> /// Initialize an existing shared information atom. This method should only be used by the XNodeInfoTable. /// </summary> public void Init(string localName, string namespaceUri, string prefix, string baseUri, XPathNode[] pageParent, XPathNode[] pageSibling, XPathNode[] pageSimilar, XPathDocument doc, int lineNumBase, int linePosBase) { Debug.Assert(localName != null && namespaceUri != null && prefix != null && doc != null); _localName = localName; _namespaceUri = namespaceUri; _prefix = prefix; _baseUri = baseUri; _pageParent = pageParent; _pageSibling = pageSibling; _pageSimilar = pageSimilar; _doc = doc; _lineNumBase = lineNumBase; _linePosBase = linePosBase; _next = null; _pageInfo = null; _hashCode = 0; _localNameHash = 0; for (int i = 0; i < _localName.Length; i++) { _localNameHash += (_localNameHash << 7) ^ _localName[i]; } }
private XPathNodeInfoAtom Atomize(XPathNodeInfoAtom info) { XPathNodeInfoAtom next = this.hashTable[info.GetHashCode() & (this.hashTable.Length - 1)]; while (next != null) { if (info.Equals(next)) { info.Next = this.infoCached; this.infoCached = info; return next; } next = next.Next; } if (this.sizeTable >= this.hashTable.Length) { XPathNodeInfoAtom[] hashTable = this.hashTable; this.hashTable = new XPathNodeInfoAtom[hashTable.Length * 2]; for (int i = 0; i < hashTable.Length; i++) { XPathNodeInfoAtom atom2; for (next = hashTable[i]; next != null; next = atom2) { atom2 = next.Next; this.AddInfo(next); } } } this.AddInfo(info); return info; }
/// <summary> /// Constructs a XPathNode. Later, the idxSibling and value fields may be fixed up. /// </summary> public void Create(XPathNodeInfoAtom info, XPathNodeType xptyp, int idxParent) { Debug.Assert(info != null && idxParent <= ushort.MaxValue); _info = info; _props = (uint)xptyp; _idxParent = (ushort)idxParent; }
private XPathNodeInfoAtom Atomize(XPathNodeInfoAtom info) { XPathNodeInfoAtom next = this.hashTable[info.GetHashCode() & (this.hashTable.Length - 1)]; while (next != null) { if (info.Equals(next)) { info.Next = this.infoCached; this.infoCached = info; return(next); } next = next.Next; } if (this.sizeTable >= this.hashTable.Length) { XPathNodeInfoAtom[] hashTable = this.hashTable; this.hashTable = new XPathNodeInfoAtom[hashTable.Length * 2]; for (int i = 0; i < hashTable.Length; i++) { XPathNodeInfoAtom atom2; for (next = hashTable[i]; next != null; next = atom2) { atom2 = next.Next; this.AddInfo(next); } } } this.AddInfo(info); return(info); }
public void SetSimilarElement(XPathNodeInfoTable infoTable, XPathNode[] pageSimilar, int idxSimilar) { this.idxSimilar = (ushort)idxSimilar; if (pageSimilar != this.info.SimilarElementPage) { this.info = infoTable.Create(this.info.LocalName, this.info.NamespaceUri, this.info.Prefix, this.info.BaseUri, this.info.ParentPage, this.info.SiblingPage, pageSimilar, this.info.Document, this.info.LineNumberBase, this.info.LinePositionBase); } }
/// <summary> /// Add a previously constructed InfoAtom to the table. If a collision occurs, then insert "info" /// as the head of a linked list. /// </summary> private void AddInfo(XPathNodeInfoAtom info) { int idx = info.GetHashCode() & (this.hashTable.Length - 1); info.Next = this.hashTable[idx]; this.hashTable[idx] = info; this.sizeTable++; }
/// <summary> /// Link this node to its next sibling. If "pageSibling" is different than the one stored in the InfoAtom, re-atomize. /// </summary> public void SetSibling(XPathNodeInfoTable infoTable, XPathNode[] pageSibling, int idxSibling) { Debug.Assert(pageSibling != null && idxSibling != 0 && idxSibling <= UInt16.MaxValue, "Bad argument"); Debug.Assert(this.idxSibling == 0, "SetSibling should not be called more than once."); this.idxSibling = (ushort)idxSibling; if (pageSibling != this.info.SiblingPage) { // Re-atomize the InfoAtom this.info = infoTable.Create(this.info.LocalName, this.info.NamespaceUri, this.info.Prefix, this.info.BaseUri, this.info.ParentPage, pageSibling, this.info.SimilarElementPage, this.info.Document, this.info.LineNumberBase, this.info.LinePositionBase); } }
/// <summary> /// Link this element to the next element in document order that shares a local name having the same hash code. /// If "pageSimilar" is different than the one stored in the InfoAtom, re-atomize. /// </summary> public void SetSimilarElement(XPathNodeInfoTable infoTable, XPathNode[] pageSimilar, int idxSimilar) { Debug.Assert(pageSimilar != null && idxSimilar != 0 && idxSimilar <= ushort.MaxValue, "Bad argument"); Debug.Assert(_idxSimilar == 0, "SetSimilarElement should not be called more than once."); _idxSimilar = (ushort)idxSimilar; if (pageSimilar != _info.SimilarElementPage) { // Re-atomize the InfoAtom _info = infoTable.Create(_info.LocalName, _info.NamespaceUri, _info.Prefix, _info.BaseUri, _info.ParentPage, _info.SiblingPage, pageSimilar, _info.Document, _info.LineNumberBase, _info.LinePositionBase); } }
public XPathNodeInfoAtom Create(string localName, string namespaceUri, string prefix, string baseUri, XPathNode[] pageParent, XPathNode[] pageSibling, XPathNode[] pageSimilar, XPathDocument doc, int lineNumBase, int linePosBase) { XPathNodeInfoAtom infoCached; if (this.infoCached == null) { infoCached = new XPathNodeInfoAtom(localName, namespaceUri, prefix, baseUri, pageParent, pageSibling, pageSimilar, doc, lineNumBase, linePosBase); } else { infoCached = this.infoCached; this.infoCached = infoCached.Next; infoCached.Init(localName, namespaceUri, prefix, baseUri, pageParent, pageSibling, pageSimilar, doc, lineNumBase, linePosBase); } return this.Atomize(infoCached); }
public XPathNodeInfoAtom Create(string localName, string namespaceUri, string prefix, string baseUri, XPathNode[] pageParent, XPathNode[] pageSibling, XPathNode[] pageSimilar, XPathDocument doc, int lineNumBase, int linePosBase) { XPathNodeInfoAtom infoCached; if (this.infoCached == null) { infoCached = new XPathNodeInfoAtom(localName, namespaceUri, prefix, baseUri, pageParent, pageSibling, pageSimilar, doc, lineNumBase, linePosBase); } else { infoCached = this.infoCached; this.infoCached = infoCached.Next; infoCached.Init(localName, namespaceUri, prefix, baseUri, pageParent, pageSibling, pageSimilar, doc, lineNumBase, linePosBase); } return(this.Atomize(infoCached)); }
private int NewNode(out XPathNode[] page, XPathNodeType xptyp, string localName, string namespaceUri, string prefix, string baseUri) { XPathNode[] nodeArray; int num; int num2; int num3; this.nodePageFact.AllocateSlot(out nodeArray, out num); this.ComputeLineInfo(XPathNavigator.IsText(xptyp), out num2, out num3); XPathNodeInfoAtom info = this.infoTable.Create(localName, namespaceUri, prefix, baseUri, this.pageParent, nodeArray, nodeArray, this.doc, this.lineNumBase, this.linePosBase); nodeArray[num].Create(info, xptyp, this.idxParent); nodeArray[num].SetLineInfoOffsets(num2, num3); page = nodeArray; return(num); }
private int NewNamespaceNode(out XPathNode[] page, string prefix, string namespaceUri, XPathNode[] pageElem, int idxElem) { XPathNode[] nodeArray; int num; int num2; int num3; this.nmspPageFact.AllocateSlot(out nodeArray, out num); this.ComputeLineInfo(false, out num2, out num3); XPathNodeInfoAtom info = this.infoTable.Create(prefix, string.Empty, string.Empty, string.Empty, pageElem, nodeArray, null, this.doc, this.lineNumBase, this.linePosBase); nodeArray[num].Create(info, XPathNodeType.Namespace, idxElem); nodeArray[num].SetValue(namespaceUri); nodeArray[num].SetLineInfoOffsets(num2, num3); page = nodeArray; return(num); }
public override string ToString() { StringBuilder builder = new StringBuilder(); for (int i = 0; i < this.hashTable.Length; i++) { builder.AppendFormat("{0,4}: ", i); for (XPathNodeInfoAtom atom = this.hashTable[i]; atom != null; atom = atom.Next) { if (atom != this.hashTable[i]) { builder.Append("\n "); } builder.Append(atom); } builder.Append('\n'); } return(builder.ToString()); }
/// <summary> /// Add a shared information item to the atomization table. If a matching item already exists, then that /// instance is returned. Otherwise, a new item is created. Thus, if itemX and itemY have both been added /// to the same InfoTable: /// 1. itemX.Equals(itemY) != true /// 2. (object) itemX != (object) itemY /// </summary> private XPathNodeInfoAtom Atomize(XPathNodeInfoAtom info) { XPathNodeInfoAtom infoNew, infoNext; // Search for existing XNodeInfoAtom in the table infoNew = this.hashTable[info.GetHashCode() & (this.hashTable.Length - 1)]; while (infoNew != null) { if (info.Equals(infoNew)) { // Found existing atom, so return that. Reuse "info". info.Next = this.infoCached; this.infoCached = info; return(infoNew); } infoNew = infoNew.Next; } // Expand table and rehash if necessary if (this.sizeTable >= this.hashTable.Length) { XPathNodeInfoAtom[] oldTable = this.hashTable; this.hashTable = new XPathNodeInfoAtom[oldTable.Length * 2]; for (int i = 0; i < oldTable.Length; i++) { infoNew = oldTable[i]; while (infoNew != null) { infoNext = infoNew.Next; AddInfo(infoNew); infoNew = infoNext; } } } // Can't find an existing XNodeInfoAtom, so use the one that was passed in AddInfo(info); return(info); }
public void Init(string localName, string namespaceUri, string prefix, string baseUri, XPathNode[] pageParent, XPathNode[] pageSibling, XPathNode[] pageSimilar, XPathDocument doc, int lineNumBase, int linePosBase) { this.localName = localName; this.namespaceUri = namespaceUri; this.prefix = prefix; this.baseUri = baseUri; this.pageParent = pageParent; this.pageSibling = pageSibling; this.pageSimilar = pageSimilar; this.doc = doc; this.lineNumBase = lineNumBase; this.linePosBase = linePosBase; this.next = null; this.pageInfo = null; this.hashCode = 0; this.localNameHash = 0; for (int i = 0; i < this.localName.Length; i++) { this.localNameHash += (this.localNameHash << 7) ^ this.localName[i]; } }
/// <summary> /// Add a previously constructed InfoAtom to the table. If a collision occurs, then insert "info" /// as the head of a linked list. /// </summary> private void AddInfo(XPathNodeInfoAtom info) { int idx = info.GetHashCode() & (_hashTable.Length - 1); info.Next = _hashTable[idx]; _hashTable[idx] = info; _sizeTable++; }
//----------------------------------------------- // Node construction //----------------------------------------------- /// <summary> /// Constructs the 0th XPathNode in each page, which contains only page information. /// </summary> public void Create(XPathNodePageInfo pageInfo) { _info = new XPathNodeInfoAtom(pageInfo); }
/// <summary> /// Add a shared information item to the atomization table. If a matching item already exists, then that /// instance is returned. Otherwise, a new item is created. Thus, if itemX and itemY have both been added /// to the same InfoTable: /// 1. itemX.Equals(itemY) != true /// 2. (object) itemX != (object) itemY /// </summary> private XPathNodeInfoAtom Atomize(XPathNodeInfoAtom info) { XPathNodeInfoAtom infoNew, infoNext; // Search for existing XNodeInfoAtom in the table infoNew = this.hashTable[info.GetHashCode() & (this.hashTable.Length - 1)]; while (infoNew != null) { if (info.Equals(infoNew)) { // Found existing atom, so return that. Reuse "info". info.Next = this.infoCached; this.infoCached = info; return infoNew; } infoNew = infoNew.Next; } // Expand table and rehash if necessary if (this.sizeTable >= this.hashTable.Length) { XPathNodeInfoAtom[] oldTable = this.hashTable; this.hashTable = new XPathNodeInfoAtom[oldTable.Length * 2]; for (int i = 0; i < oldTable.Length; i++) { infoNew = oldTable[i]; while (infoNew != null) { infoNext = infoNew.Next; AddInfo(infoNew); infoNew = infoNext; } } } // Can't find an existing XNodeInfoAtom, so use the one that was passed in AddInfo(info); return info; }
/// <summary> /// Create a new XNodeInfoAtom and ensure it is atomized in the table. /// </summary> public XPathNodeInfoAtom Create(string localName, string namespaceUri, string prefix, string baseUri, XPathNode[] pageParent, XPathNode[] pageSibling, XPathNode[] pageSimilar, XPathDocument doc, int lineNumBase, int linePosBase) { XPathNodeInfoAtom info; // If this.infoCached already exists, then reuse it; else create new InfoAtom if (this.infoCached == null) { info = new XPathNodeInfoAtom(localName, namespaceUri, prefix, baseUri, pageParent, pageSibling, pageSimilar, doc, lineNumBase, linePosBase); } else { info = this.infoCached; this.infoCached = info.Next; info.Init(localName, namespaceUri, prefix, baseUri, pageParent, pageSibling, pageSimilar, doc, lineNumBase, linePosBase); } return Atomize(info); }
/// <summary> /// Link this element to the next element in document order that shares a local name having the same hash code. /// If "pageSimilar" is different than the one stored in the InfoAtom, re-atomize. /// </summary> public void SetSimilarElement(XPathNodeInfoTable infoTable, XPathNode[] pageSimilar, int idxSimilar) { Debug.Assert(pageSimilar != null && idxSimilar != 0 && idxSimilar <= UInt16.MaxValue, "Bad argument"); Debug.Assert(this.idxSimilar == 0, "SetSimilarElement should not be called more than once."); this.idxSimilar = (ushort)idxSimilar; if (pageSimilar != this.info.SimilarElementPage) { // Re-atomize the InfoAtom this.info = infoTable.Create(this.info.LocalName, this.info.NamespaceUri, this.info.Prefix, this.info.BaseUri, this.info.ParentPage, this.info.SiblingPage, pageSimilar, this.info.Document, this.info.LineNumberBase, this.info.LinePositionBase); } }
/// <summary> /// Constructs a XPathNode. Later, the idxSibling and value fields may be fixed up. /// </summary> public void Create(XPathNodeInfoAtom info, XPathNodeType xptyp, int idxParent) { Debug.Assert(info != null && idxParent <= UInt16.MaxValue); this.info = info; this.props = (uint)xptyp; this.idxParent = (ushort)idxParent; }
//----------------------------------------------- // Node construction //----------------------------------------------- /// <summary> /// Constructs the 0th XPathNode in each page, which contains only page information. /// </summary> public void Create(XPathNodePageInfo pageInfo) { this.info = new XPathNodeInfoAtom(pageInfo); }
public void Create(XPathNodeInfoAtom info, XPathNodeType xptyp, int idxParent) { this.info = info; this.props = (uint) xptyp; this.idxParent = (ushort) idxParent; }
public void SetSimilarElement(XPathNodeInfoTable infoTable, XPathNode[] pageSimilar, int idxSimilar) { this.idxSimilar = (ushort) idxSimilar; if (pageSimilar != this.info.SimilarElementPage) { this.info = infoTable.Create(this.info.LocalName, this.info.NamespaceUri, this.info.Prefix, this.info.BaseUri, this.info.ParentPage, this.info.SiblingPage, pageSimilar, this.info.Document, this.info.LineNumberBase, this.info.LinePositionBase); } }
public void Create(XPathNodeInfoAtom info, XPathNodeType xptyp, int idxParent) { this.info = info; this.props = (uint)xptyp; this.idxParent = (ushort)idxParent; }
/// <summary> /// Link this node to its next sibling. If "pageSibling" is different than the one stored in the InfoAtom, re-atomize. /// </summary> public void SetSibling(XPathNodeInfoTable infoTable, XPathNode[] pageSibling, int idxSibling) { Debug.Assert(pageSibling != null && idxSibling != 0 && idxSibling <= UInt16.MaxValue, "Bad argument"); Debug.Assert(_idxSibling == 0, "SetSibling should not be called more than once."); _idxSibling = (ushort)idxSibling; if (pageSibling != _info.SiblingPage) { // Re-atomize the InfoAtom _info = infoTable.Create(_info.LocalName, _info.NamespaceUri, _info.Prefix, _info.BaseUri, _info.ParentPage, pageSibling, _info.SimilarElementPage, _info.Document, _info.LineNumberBase, _info.LinePositionBase); } }
/// <summary> /// Initialize an existing shared information atom. This method should only be used by the XNodeInfoTable. /// </summary> public void Init(string localName, string namespaceUri, string prefix, string baseUri, XPathNode[] pageParent, XPathNode[] pageSibling, XPathNode[] pageSimilar, XPathDocument doc, int lineNumBase, int linePosBase) { Debug.Assert(localName != null && namespaceUri != null && prefix != null && doc != null); _localName = localName; _namespaceUri = namespaceUri; _prefix = prefix; _baseUri = baseUri; _pageParent = pageParent; _pageSibling = pageSibling; _pageSimilar = pageSimilar; _doc = doc; _lineNumBase = lineNumBase; _linePosBase = linePosBase; _next = null; _pageInfo = null; _hashCode = 0; _localNameHash = 0; for (int i = 0; i < _localName.Length; i++) _localNameHash += (_localNameHash << 7) ^ _localName[i]; }
public override bool Equals(object other) { XPathNodeInfoAtom atom = other as XPathNodeInfoAtom; return(((((this.GetHashCode() == atom.GetHashCode()) && (this.localName == atom.localName)) && ((this.pageSibling == atom.pageSibling) && (this.namespaceUri == atom.namespaceUri))) && (((this.pageParent == atom.pageParent) && (this.pageSimilar == atom.pageSimilar)) && ((this.prefix == atom.prefix) && (this.baseUri == atom.baseUri)))) && ((this.lineNumBase == atom.lineNumBase) && (this.linePosBase == atom.linePosBase))); }