public static LSL_List ToDoubleList(LSL_List src) { LSL_List ret = new LSL_List(); double entry; for (int i = 0; i < src.Data.Length - 1; i++) { if (double.TryParse(src.Data[i].ToString(), out entry)) { ret.Add(entry); } } return ret; }
public LSL_List GetSublist(int start, int end) { object[] ret; // Take care of neg start or end's // NOTE that either index may still be negative after // adding the length, so we must take additional // measures to protect against this. Note also that // after normalisation the negative indices are no // longer relative to the end of the list. if (start < 0) { start = value.Length + start; } if (end < 0) { end = value.Length + end; } // The conventional case is start <= end // NOTE that the case of an empty list is // dealt with by the initial test. Start // less than end is taken to be the most // common case. if (start <= end) { // Start sublist beyond length // Also deals with start AND end still negative if (start >= value.Length || end < 0) { return new LSL_List(); } // Sublist extends beyond the end of the supplied list if (end >= value.Length) { end = value.Length - 1; } // Sublist still starts before the beginning of the list if (start < 0) { start = 0; } ret = new object[end - start + 1]; Array.Copy(value, start, ret, 0, end - start + 1); return new LSL_List(ret); } // Deal with the segmented case: 0->end + start->EOL else { LSL_List result = null; // If end is negative, then prefix list is empty if (end < 0) { result = new LSL_List(); // If start is still negative, then the whole of // the existing list is returned. This case is // only admitted if end is also still negative. if (start < 0) { return this; } } else { result = GetSublist(0, end); } // If start is outside of list, then just return // the prefix, whatever it is. if (start >= value.Length) { return result; } return result + GetSublist(start, Data.Length); } }