When creating a sublist from a sublist the implementation of subListįrom AbstractList is used. With this change, when calling subList from a sublist, we return a sublist holding a reference to the original list instead of to the parent sublist, which frees the parent sublist for garbage collection and allows the child sublist to access elements by calling directly the get function of the original list. Moreover, it can also make accessing elements of the sublist slower, as each sublist must call the get function from the sublist it originated from to access the element. This prevents the parent sublist from being ellegible for garbage collection as long as the child sublist is needed, and can lead to StackOverflowError or OutOfMemoryError errors if multiple calls to subList are chained. This implementation treats the parent sublist as a list in its own right, and this leads to the child sublist holding a reference to the parent sublist, when holding a reference to the original list would suffice. When creating a sublist from a sublist the implementation of subList from AbstractList is used.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |