for (PRInt32 i = 1; i < mRangeArray->Count();i++) { mRangeArray->RemoveElementAt(i); }
Clear();
nsRangeList::Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset){  nsresult res;  // Clear all but one of the ranges; we'll reuse the first one.  if (!mRangeArray)    return NS_ERROR_FAILURE;  for (PRInt32 i = 1; i < mRangeArray->Count();i++)  {    mRangeArray->RemoveElementAt(i);  }  nsCOMPtr<nsIDOMRange> range;  if (mRangeArray->Count() < 1)  {    res = nsRepository::CreateInstance(kRangeCID, nsnull,                                       kIDOMRangeIID,                                       getter_AddRefs(range));    if (!NS_SUCCEEDED(res))      return res;    res = AddItem(range);    if (!NS_SUCCEEDED(res))      return res;  }  nsCOMPtr<nsISupports> firstElement (mRangeArray->ElementAt(0));  res = firstElement->QueryInterface(kIDOMRangeIID, getter_AddRefs(range));  if (!NS_SUCCEEDED(res))    return res;  res = range->SetEnd(aParentNode, aOffset);  if (!NS_SUCCEEDED(res))    return res;  res = range->SetStart(aParentNode, aOffset);  if (!NS_SUCCEEDED(res))    return res;  setAnchor(aParentNode, aOffset);  setFocus(aParentNode, aOffset);  return NS_OK;}