/** * Adds a new element to the end of the list and returns it. If the inner array isn't large enough * then the oldest element will be written over. * @return instance at the tail */ public T growW() { T a; if( size >= data.length) { a = data[start]; if( a == null ) data[start] = a = createInstance(); start = (start+1)%data.length; } else { a = data[(start+size)%data.length]; if( a == null ) data[(start+size)%data.length] = a = createInstance(); size++; } return a; }
/** * Adds a new element to the end of the list and returns it. If the inner array isn't large enough * then the oldest element will be written over. * @return instance at the tail */ public T growW() { T a; if( size >= data.length) { a = data[start]; if( a == null ) data[start] = a = createInstance(); start = (start+1)%data.length; } else { a = data[(start+size)%data.length]; if( a == null ) data[(start+size)%data.length] = a = createInstance(); size++; } return a; }
/** * Adds a new element to the end of the list and returns it. If the inner array isn't large enough * then it will grow. * @return instance at the tail */ public T grow() { if( size >= data.length) { T a = createInstance(); add(a); return a; } else { T a = data[(start+size)%data.length]; if( a == null ) { data[(start+size)%data.length] = a = createInstance(); } size++; return a; } }
/** * Adds a new element to the end of the list and returns it. If the inner array isn't large enough * then it will grow. * @return instance at the tail */ public T grow() { if( size >= data.length) { T a = createInstance(); add(a); return a; } else { T a = data[(start+size)%data.length]; if( a == null ) { data[(start+size)%data.length] = a = createInstance(); } size++; return a; } }