@SuppressWarnings("unchecked")
void add(T t, ListenableCollection<T> source, ListenableCollection<T> recipient) {
if ((recipient instanceof List) && (source instanceof SortedSet)) {
ListenableList<T> recipientList = (ListenableList<T>)recipient;
Comparator<T> comparator = (Comparator<T>) ((SortedSet)source).comparator();
int i;
if (comparator != null) {
i = Collections.binarySearch(recipientList, t, comparator);
} else {
i = Collections.binarySearch((List)recipientList, t);
}
if (i >= 0) {
recipientList.set(i, t);
} else {
recipientList.add(-i - 1, t);
}
} else {
recipient.add(t);
}
}
@SuppressWarnings("unchecked")