private PointTransitions Next(int point) { // 1st time we are seeing this point if (count == points.Length) { // LUCENENET: Resize rather than copy Array.Resize(ref points, ArrayUtil.Oversize(1 + count, RamUsageEstimator.NUM_BYTES_OBJECT_REF)); } PointTransitions points0 = points[count]; if (points0 == null) { points0 = points[count] = new PointTransitions(); } points0.Reset(point); count++; return(points0); }
private PointTransitions Next(int point) { // 1st time we are seeing this point if (count == points.Length) { PointTransitions[] newArray = new PointTransitions[ArrayUtil.Oversize(1 + count, RamUsageEstimator.NUM_BYTES_OBJECT_REF)]; Array.Copy(points, 0, newArray, 0, count); points = newArray; } PointTransitions points0 = points[count]; if (points0 == null) { points0 = points[count] = new PointTransitions(); } points0.Reset(point); count++; return(points0); }
private PointTransitions Find(int point) { if (useHash) { int?pi = point; if (!map.TryGetValue(pi, out PointTransitions p)) { p = Next(point); map[pi] = p; } return(p); } else { for (int i = 0; i < count; i++) { if (points[i].point == point) { return(points[i]); } } PointTransitions p = Next(point); if (count == HASHMAP_CUTOVER) { // switch to HashMap on the fly if (Debugging.AssertsEnabled) { Debugging.Assert(map.Count == 0); } for (int i = 0; i < count; i++) { map[points[i].point] = points[i]; } useHash = true; } return(p); } }
internal PointTransitions Find(int point) { if (UseHash) { int?pi = point; PointTransitions p; if (!Map.TryGetValue(pi, out p)) { p = Next(point); Map[pi] = p; } return(p); } else { for (int i = 0; i < Count; i++) { if (Points[i].Point == point) { return(Points[i]); } } PointTransitions p = Next(point); if (Count == HASHMAP_CUTOVER) { // switch to HashMap on the fly Debug.Assert(Map.Count == 0); for (int i = 0; i < Count; i++) { Map[Points[i].Point] = Points[i]; } UseHash = true; } return(p); } }