W RandomAccess opisu interfejsu znacznik jest napisane:Kiedy są stosowane algorytmy do manipulowania listami dostępu swobodnego?
* <p>The best algorithms for manipulating random access lists (such as
* <tt>ArrayList</tt>) can produce quadratic behavior when applied to
* sequential access lists (such as <tt>LinkedList</tt>). Generic list
* algorithms are encouraged to check whether the given list is an
* <tt>instanceof</tt> this interface before applying an algorithm that would
* provide poor performance if it were applied to a sequential access list,
* and to alter their behavior if necessary to guarantee acceptable
* performance.
W metodzie synchronisedList klasy kolekcja jest czek na RandomAccess & jeśli sukces utworzyć obiektu SynchronizedRandomAccessList ale ich też żadnych szczegółów dotyczących algorytmu.
public static <T> List<T> synchronizedList(List<T> list) {
return (list instanceof RandomAccess ?
new SynchronizedRandomAccessList<T>(list) :
new SynchronizedList<T>(list));
}
Kiedy stosuje się ten algorytm i gdzie (czy jest to kod natywny)?
'synchronizedList' tworzy danych struktura, to naprawdę nie jest algorytm ... –
@OliCharlesworth to prawda, ale patrz komentarz Dokumenty, mówimy o algorytmie ... im zapytaniem kiedy i gdzie algorytm jest stosowany – Prateek
Co algorytm, do którego się odnosisz? –