public override bool Equals(object obj) { WeakRefCollection other = obj as WeakRefCollection; if (other == this) { return(true); } if (other == null || Count != other.Count) { return(false); } for (int i = 0; i < Count; i++) { if (InnerList[i] != other.InnerList[i]) { if (InnerList[i] == null || !InnerList[i].Equals(other.InnerList[i])) { return(false); } } } return(true); }
private static void Copy(WeakRefCollection sourceList, int sourceIndex, WeakRefCollection destinationList, int destinationIndex, int length) { if (sourceIndex < destinationIndex) { // We need to copy from the back forward to prevent overwrite if source and // destination lists are the same, so we need to flip the source/dest indices // to point at the end of the spans to be copied. sourceIndex += length; destinationIndex += length; for (; length > 0; length--) { destinationList.InnerList[--destinationIndex] = sourceList.InnerList[--sourceIndex]; } } else { for (; length > 0; length--) { destinationList.InnerList[destinationIndex++] = sourceList.InnerList[sourceIndex++]; } } }