@@ -155,10 +155,14 @@ protected Double2[] getSubArray(int[] indices){
155155 sub [i ] = values [indices [i ]];
156156 return sub ;
157157 }
158-
158+
159159 public void set (int index , Entity value ) throws Exception {
160- values [index ].x = ((BasicPoint )value ).getX ();
161- values [index ].y = ((BasicPoint )value ).getY ();
160+ if (value == null ) {
161+ setNull (index );
162+ } else {
163+ values [index ].x = ((BasicPoint )value ).getX ();
164+ values [index ].y = ((BasicPoint )value ).getY ();
165+ }
162166 }
163167
164168 @ Override
@@ -168,14 +172,21 @@ public void set(int index, Object value) {
168172 } else if (value instanceof Double2 ) {
169173 Double2 d2 = (Double2 ) value ;
170174 setPoint (index , d2 .x , d2 .y );
175+ } else if (value instanceof BasicPoint ) {
176+ BasicPoint bp = (BasicPoint ) value ;
177+ setPoint (index , bp .getX (), bp .getY ());
171178 } else {
172- throw new IllegalArgumentException ("Unsupported type: " + value .getClass ().getName () + ". Only Double2 or null is supported." );
179+ throw new IllegalArgumentException ("Unsupported type: " + value .getClass ().getName () + ". Only Double2, BasicPoint or null is supported." );
173180 }
174181 }
175182
176183 public void setPoint (int index , double x , double y ){
177- values [index ].x = x ;
178- values [index ].y = y ;
184+ if (values [index ] == null ) {
185+ values [index ] = new Double2 (x , y );
186+ } else {
187+ values [index ].x = x ;
188+ values [index ].y = y ;
189+ }
179190 }
180191
181192 @ Override
@@ -202,13 +213,13 @@ public void add(Object value) {
202213 public void add (Double2 value ) {
203214 if (size + 1 > capacity && values .length > 0 ){
204215 values = Arrays .copyOf (values , values .length * 2 );
205- }else if (values .length <= 0 ){
216+ } else if (values .length <= 0 ){
206217 values = Arrays .copyOf (values , values .length + 1 );
207218 }
208219 capacity = values .length ;
209220
210221 if (value == null ) {
211- values [size ]. setNull ( );
222+ values [size ] = new Double2 (- Double . MAX_VALUE , - Double . MAX_VALUE );
212223 } else {
213224 values [size ] = value ;
214225 }
0 commit comments