...
In this compliant solution, rather than use a dead flag, the programmer assigns null
to ArrayList
elements that have become irrelevant.:
Code Block | ||
---|---|---|
| ||
class DataElement { // Dead flag removed // Other fields } // Elsewhere ArrayList longLivedList = new ArrayList<DataElement>(...); // Processing that renders an element irrelevant // Set the reference to the irrelevant DataElement to null longLivedList.set(someIndex, null); |
...