public DreamList CreateCopy(int start = 1, int end = 0) { if (start == 0) { ++start; //start being 0 and start being 1 are equivalent } if (end > _values.Count + 1) { throw new Exception("list index out of bounds"); } if (end == 0) { end = _values.Count + 1; } DreamList copy = Create(end); for (int i = start; i < end; i++) { DreamValue value = _values[i - 1]; copy._values.Add(value); if (ContainsKey(value)) { copy.SetValue(value, _associativeValues[value]); } } return(copy); }
public DreamList Union(DreamList other) { DreamList newList = new DreamList(); newList._values = _values.Union(other.GetValues()).ToList(); foreach ((DreamValue key, DreamValue value) in other.GetAssociativeValues()) { newList.SetValue(key, value); } return(newList); }