[Biojava-l] Re: More Questions on behavior of SymbolList

Christopher Pickslay chrispix@bigfoot.com
Thu, 06 Sep 2001 17:07:35 -0700


It seems that the default behavior of subList should be to return a copy, 
in keeping with the behavior of similar methods, like 
java.util.List.subList() and java.lang.String.subString().

Then you could provide the overloaded method subList(int start, int end, 
boolean reflectChanges), where reflectChanges determines whether this 
SymbolList should listen for changes in the underlying SymbolList.

One good reason for this is that subList(x,y,true) should return an 
*immutable* SymbolList. Otherwise, if the SymbolList returned were 
editable, how would you reconcile direct edits to the sub-list with changes 
to the underlying SymbolList? Even if we devised a programmatic solution, 
the behavior would be hard to predict in practice.

Christopher

At 10:49 AM 9/6/2001 -0400, you wrote:

>         I like the idea of getting a copy(ie not referencing the original)
>of the data when getting a SubList. If others disagree that this should be
>the default, then lets create two functions, one that returns a view, and
>another that returns a copy.