public override AbstractEdgeMap <T> Put(int key, T value) { if (key < minIndex || key > maxIndex) { return(this); } if (key == this.key || this.value == null) { return(new erl.Oracle.TnsNames.Antlr4.Runtime.Dfa.SingletonEdgeMap <T>(minIndex, maxIndex, key, value)); } else { if (value != null) { AbstractEdgeMap <T> result = new SparseEdgeMap <T>(minIndex, maxIndex); result = result.Put(this.key, this.value); result = result.Put(key, value); return(result); } else { return(this); } } }
public override AbstractEdgeMap <T> PutAll(IEdgeMap <T> m) { if (m.IsEmpty) { return(this); } if (m is erl.Oracle.TnsNames.Antlr4.Runtime.Dfa.ArrayEdgeMap <T> ) { erl.Oracle.TnsNames.Antlr4.Runtime.Dfa.ArrayEdgeMap <T> other = (erl.Oracle.TnsNames.Antlr4.Runtime.Dfa.ArrayEdgeMap <T>)m; int minOverlap = Math.Max(minIndex, other.minIndex); int maxOverlap = Math.Min(maxIndex, other.maxIndex); erl.Oracle.TnsNames.Antlr4.Runtime.Dfa.ArrayEdgeMap <T> result = this; for (int i = minOverlap; i <= maxOverlap; i++) { result = ((erl.Oracle.TnsNames.Antlr4.Runtime.Dfa.ArrayEdgeMap <T>)result.Put(i, m[i])); } return(result); } else { if (m is SingletonEdgeMap <T> ) { SingletonEdgeMap <T> other = (SingletonEdgeMap <T>)m; System.Diagnostics.Debug.Assert(!other.IsEmpty); return(Put(other.Key, other.Value)); } else { if (m is SparseEdgeMap <T> ) { SparseEdgeMap <T> other = (SparseEdgeMap <T>)m; lock (other) { int[] keys = other.Keys; IList <T> values = other.Values; erl.Oracle.TnsNames.Antlr4.Runtime.Dfa.ArrayEdgeMap <T> result = this; for (int i = 0; i < values.Count; i++) { result = ((erl.Oracle.TnsNames.Antlr4.Runtime.Dfa.ArrayEdgeMap <T>)result.Put(keys[i], values[i])); } return(result); } } else { throw new NotSupportedException(string.Format("EdgeMap of type {0} is supported yet.", m.GetType().FullName)); } } } }