public override bool Equals(object obj) { ArrayDimension other = obj as ArrayDimension; if (other == null) { return(false); } return(this.lowerBound == other.lowerBound && this.upperBound == other.upperBound); }
IEnumerable<TreeNode> LazyGetChildren() { // The whole array is small - just add all elements as childs if (bounds.TotalElementCount <= MaxElementCount) { foreach(int[] indices in bounds.Indices) { string imageName; var image = ExpressionNode.GetImageForArrayIndexer(out imageName); var expression = new ExpressionNode(image, GetName(indices), arrayTarget.AppendIndexer(indices)); expression.ImageName = imageName; yield return expression; } yield break; } // Find a dimension of size at least 2 int splitDimensionIndex = bounds.Count - 1; for(int i = 0; i < bounds.Count; i++) { if (bounds[i].Count > 1) { splitDimensionIndex = i; break; } } ArrayDimension splitDim = bounds[splitDimensionIndex]; // Split the dimension int elementsPerSegment = 1; while (splitDim.Count > elementsPerSegment * MaxElementCount) { elementsPerSegment *= MaxElementCount; } for(int i = splitDim.LowerBound; i <= splitDim.UpperBound; i += elementsPerSegment) { List<ArrayDimension> newDims = new List<ArrayDimension>(bounds); newDims[splitDimensionIndex] = new ArrayDimension(i, Math.Min(i + elementsPerSegment - 1, splitDim.UpperBound)); yield return new ArrayRangeNode(arrayTarget, new ArrayDimensions(newDims), originalBounds); } yield break; }