//----------------------------------------------- // Indexes //----------------------------------------------- /// <summary> /// If an index having the specified Id has already been created over the "context" document, then return it /// in "index" and return true. Otherwise, create a new, empty index and return false. /// </summary> public bool FindIndex(XPathNavigator context, int indexId, out XmlILIndex index) { XPathNavigator navRoot; ArrayList docIndexes; Debug.Assert(context != null); // Get root of document navRoot = context.Clone(); navRoot.MoveToRoot(); // Search pre-existing indexes in order to determine whether the specified index has already been created if (_indexes != null && indexId < _indexes.Length) { docIndexes = (ArrayList)_indexes[indexId]; if (docIndexes != null) { // Search for an index defined over the specified document for (int i = 0; i < docIndexes.Count; i += 2) { // If we find a matching document, then return the index saved in the next slot if (((XPathNavigator)docIndexes[i]).IsSamePosition(navRoot)) { index = (XmlILIndex)docIndexes[i + 1]; return(true); } } } } // Return a new, empty index index = new XmlILIndex(); return(false); }
/// <summary> /// Add a newly built index over the specified "context" document to the existing collection of indexes. /// </summary> public void AddNewIndex(XPathNavigator context, int indexId, XmlILIndex index) { XPathNavigator navRoot; ArrayList docIndexes; Debug.Assert(context != null); // Get root of document navRoot = context.Clone(); navRoot.MoveToRoot(); // Ensure that a slot exists for the new index if (_indexes == null) { _indexes = new ArrayList[indexId + 4]; } else if (indexId >= _indexes.Length) { // Resize array ArrayList[] indexesNew = new ArrayList[indexId + 4]; Array.Copy(_indexes, indexesNew, _indexes.Length); _indexes = indexesNew; } docIndexes = (ArrayList)_indexes[indexId]; if (docIndexes == null) { docIndexes = new ArrayList(); _indexes[indexId] = docIndexes; } docIndexes.Add(navRoot); docIndexes.Add(index); }
/// <summary> /// Add a newly built index over the specified "context" document to the existing collection of indexes. /// </summary> public void AddNewIndex(XPathNavigator context, int indexId, XmlILIndex index) { XPathNavigator navRoot; ArrayList docIndexes; Debug.Assert(context != null); // Get root of document navRoot = context.Clone(); navRoot.MoveToRoot(); // Ensure that a slot exists for the new index if (this.indexes == null) { this.indexes = new ArrayList[indexId + 4]; } else if (indexId >= this.indexes.Length) { // Resize array ArrayList[] indexesNew = new ArrayList[indexId + 4]; Array.Copy(this.indexes, 0, indexesNew, 0, this.indexes.Length); this.indexes = indexesNew; } docIndexes = (ArrayList) this.indexes[indexId]; if (docIndexes == null) { docIndexes = new ArrayList(); this.indexes[indexId] = docIndexes; } docIndexes.Add(navRoot); docIndexes.Add(index); }
//----------------------------------------------- // Indexes //----------------------------------------------- /// <summary> /// If an index having the specified Id has already been created over the "context" document, then return it /// in "index" and return true. Otherwise, create a new, empty index and return false. /// </summary> public bool FindIndex(XPathNavigator context, int indexId, out XmlILIndex index) { XPathNavigator navRoot; ArrayList docIndexes; Debug.Assert(context != null); // Get root of document navRoot = context.Clone(); navRoot.MoveToRoot(); // Search pre-existing indexes in order to determine whether the specified index has already been created if (this.indexes != null && indexId < this.indexes.Length) { docIndexes = (ArrayList) this.indexes[indexId]; if (docIndexes != null) { // Search for an index defined over the specified document for (int i = 0; i < docIndexes.Count; i += 2) { // If we find a matching document, then return the index saved in the next slot if (((XPathNavigator) docIndexes[i]).IsSamePosition(navRoot)) { index = (XmlILIndex) docIndexes[i + 1]; return true; } } } } // Return a new, empty index index = new XmlILIndex(); return false; }