blib/lib/SPVM/Array.pm untested

filter: Statementstmt n/a Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a SCAR -
1 package SPVM::Array;
2  
3 1;
4  
5 =encoding utf8
6  
7 =head1 Name
8  
9 SPVM::Array - Array Utilities
10  
11 =head1 Usage
12  
13 use Array;
14
15 # Copy a byte array
16 {
17 my $array = [(byte)1, 2, 3];
18 my $array_copy = Array->copy_byte($array);
19 }
20  
21 # Copy a short array
22 {
23 my $array = [(short)1, 2, 3];
24 my $array_copy = Array->copy_short($array);
25 }
26  
27 # Copy a int array
28 {
29 my $array = [1, 2, 3];
30 my $array_copy = Array->copy_int($array);
31 }
32  
33 # Copy a long array
34 {
35 my $array = [(long)1, 2, 3];
36 my $array_copy = Array->copy_long($array);
37 }
38  
39 # Copy a float array
40 {
41 my $array = [1.5f, 2.5f, 3.5f];
42 my $array_copy = Array->copy_float($array);
43 }
44  
45 # Copy a double array
46 {
47 my $array = [1.5, 2.5, 3.5];
48 my $array_copy = Array->copy_double($array);
49 }
50
51 # Copy a string array
52 {
53 my $array = ["abc", "def", "ghi"]
54 my $array_copy = Array->copy_string($array);
55 }
56
57 # Check if the two byte arrays equal
58 {
59 my $array1 = [(byte)1, 2];
60 my $array2 = [(byte)1, 2];
61 my $ret = Array->equals_byte($array1, $array2);
62 }
63  
64 # Check if the two short arrays equal
65 {
66 my $array1 = [(short)1, 2];
67 my $array2 = [(short)1, 2];
68 my $ret = Array->equals_short($array1, $array2);
69 }
70  
71 # Check if the two int arrays equal
72 {
73 my $array1 = [(int)1, 2];
74 my $array2 = [(int)1, 2];
75 my $ret = Array->equals_int($array1, $array2);
76 }
77  
78 # Check if the two long arrays equal
79 {
80 my $array1 = [(long)1, 2];
81 my $array2 = [(long)1, 2];
82 my $ret = Array->equals_long($array1, $array2);
83 }
84  
85 # Check if the two float arrays equal
86 {
87 my $array1 = [(float)1, 2];
88 my $array2 = [(float)1, 2];
89 my $ret = Array->equals_float($array1, $array2);
90 }
91  
92 # Check if the two double arrays equal
93 {
94 my $array1 = [(double)1, 2];
95 my $array2 = [(double)1, 2];
96 my $ret = Array->equals_double($array1, $array2);
97 }
98  
99 # Check if the two string arrays equal
100 {
101 my $array1 = ["abc", "def"];
102 my $array2 = ["abc", "def"];
103 my $ret = Array->equals_string($array1, $array2);
104 }
105
106 # Copy object array
107 my $array = [(object)Int->new(1), Int->new(2), Int->new(3)];
108 my $array_copy = Array->copy_object($array, method : object ($obj : object) {
109 my $int_obj = (Int)$obj;
110 my $new_int_obj = Int->new($int_obj->value);
111 return $new_int_obj;
112 });
113  
114 =head1 Description
115  
116 C<Array> provides array utilities.
117  
118 =head1 Class Methods
119  
120 =head2 copy_byte
121  
122 C<static method copy_byte : byte[] ($array : byte[], $offset : int = 0, $length : int = -1);>
123  
124 Create a new C<byte> array with $length, and copy the elements from $offset to the position proceeded by $length to the created array.
125  
126 If $length is less than 0, it is the length of $array minus $offset.
127  
128 Exceptions:
129  
130 $array must be defined. Otherwise an exception is thrown.
131  
132 $offset must be greater than or equal to 0. Otherwise an exception is thrown.
133  
134 $offset + $length must be less than or equal to the length of $array. Otherwise an exception is thrown.
135  
136 =head2 copy_double
137  
138 C<static method copy_double : double[] ($array : double[], $offset : int = 0, $length : int = -1);>
139  
140 Create a new C<double> array with $length, and copy the elements from $offset to the position proceeded by $length to the created array.
141  
142 If $length is less than 0, it is the length of $array minus $offset.
143  
144 If the array is not defined, return undef.
145  
146 Exceptions:
147  
148 $array must be defined. Otherwise an exception is thrown.
149  
150 $offset must be greater than or equal to 0. Otherwise an exception is thrown.
151  
152 $offset + $length must be less than or equal to the length of $array. Otherwise an exception is thrown.
153  
154 =head2 copy_float
155  
156 C<static method copy_float : float[] ($array : float[], $offset : int = 0, $length : int = -1);>
157  
158 Create a new C<float> array with $length, and copy the elements from $offset to the position proceeded by $length to the created array.
159  
160 If $length is less than 0, it is the length of $array minus $offset.
161  
162 Exceptions:
163  
164 $array must be defined. Otherwise an exception is thrown.
165  
166 $offset must be greater than or equal to 0. Otherwise an exception is thrown.
167  
168 $offset + $length must be less than or equal to the length of $array. Otherwise an exception is thrown.
169  
170 =head2 copy_int
171  
172 C<static method copy_int : int[] ($array : int[], $offset : int = 0, $length : int = -1);>
173  
174 Create a new C<int> array with $length, and copy the elements from $offset to the position proceeded by $length to the created array.
175  
176 If $length is less than 0, it is the length of $array minus $offset.
177  
178 Exceptions:
179  
180 $array must be defined. Otherwise an exception is thrown.
181  
182 $offset must be greater than or equal to 0. Otherwise an exception is thrown.
183  
184 $offset + $length must be less than or equal to the length of $array. Otherwise an exception is thrown.
185  
186 =head2 copy_long
187  
188 C<static method copy_long : long[] ($array : long[], $offset : int = 0, $length : int = -1);>
189  
190 Create a new C<long> array with $length, and copy the elements from $offset to the position proceeded by $length to the created array.
191  
192 If $length is less than 0, it is the length of $array minus $offset.
193  
194 Exceptions:
195  
196 $array must be defined. Otherwise an exception is thrown.
197  
198 $offset must be greater than or equal to 0. Otherwise an exception is thrown.
199  
200 $offset + $length must be less than or equal to the length of $array. Otherwise an exception is thrown.
201  
202 =head2 copy_object
203  
204 C<static method copy_object : object[] ($array : object[], $cloner : L<Cloner|SPVM::Cloner> = undef, $offset : int = 0, $legnth : int = -1);>
205  
206 Create a new object array with $length, and clone the elements of the object array from $offset to the position proceeded by $length to the created array.
207  
208 Each element is cloned by L<Cloner|SPVM::Cloner>.
209  
210 If the cloner is not defined, the address of each element is copied.
211  
212 If $length is less than 0, it is the length of $array minus $offset.
213  
214 Exceptions:
215  
216 $array must be defined. Otherwise an exception is thrown.
217  
218 $offset must be greater than or equal to 0. Otherwise an exception is thrown.
219  
220 $offset + $length must be less than or equal to the length of $array. Otherwise an exception is thrown.
221  
222 =head2 copy_object_address
223  
224 C<static method copy_object_address : object[] ($array : object[], $offset : int = 0, $legnth : int = -1);>
225  
226 The alias for the following code using L</"copy_object">.
227  
228 my $ret = &copy_object($array, undef, $offset, $length);
229  
230 =head2 copy_short
231  
232 C<static method copy_short : short[] ($array : short[], $offset : int = 0, $length : int = -1);>
233  
234 Create a new C<short> array with $length, and copy the elements from $offset to the position proceeded by $length to the created array.
235  
236 If $length is less than 0, it is the length of $array minus $offset.
237  
238 Exceptions:
239  
240 $array must be defined. Otherwise an exception is thrown.
241  
242 $offset must be greater than or equal to 0. Otherwise an exception is thrown.
243  
244 $offset + $length must be less than or equal to the length of $array. Otherwise an exception is thrown.
245  
246 =head2 copy_string
247  
248 C<static method copy_string : string[] ($array : string[], $offset : int = 0, $length : int = -1);>
249  
250 Create a new C<string> array with $length, and copy the elements of the C<string> array using C<copy> operator from $offset to the position proceeded by $length to the created array.
251  
252 If $length is less than 0, it is the length of $array minus $offset.
253  
254 Exceptions:
255  
256 $array must be defined. Otherwise an exception is thrown.
257  
258 $offset must be greater than or equal to 0. Otherwise an exception is thrown.
259  
260 $offset + $length must be less than or equal to the length of $array. Otherwise an exception is thrown.
261  
262 =head2 copy_string_address
263  
264 C<static method copy_string_address : string[] ($array : string[], $offset : int = 0, $length : int = -1);>
265  
266 Create a new C<string> array with $length, and copy the addresses of the elements of the C<string> array from $offset to the position proceeded by $length to the created array.
267  
268 If $length is less than 0, it is the length of $array minus $offset.
269  
270 Exceptions:
271  
272 $array must be defined. Otherwise an exception is thrown.
273  
274 $offset must be greater than or equal to 0. Otherwise an exception is thrown.
275  
276 $offset + $length must be less than or equal to the length of $array. Otherwise an exception is thrown.
277  
278 =head2 dump_unsigned_byte
279  
280 C<static method dump_unsigned_byte : string ($array : byte[]);>
281  
282 Same as the following code using the L<dump operator|SPVM::Document::Language/"dump Operator"> operator, but the elements are displayed as unsigned 8-bit integer.
283  
284 my $ret = dump $array;
285  
286 =head2 dump_unsigned_int
287  
288 C<static method dump_unsigned_int : string ($array : int[]);>
289  
290 Same as the following code using the L<dump operator|SPVM::Document::Language/"dump Operator"> operator, but the elements are displayed as unsigned 32-bit integer.
291  
292 my $ret = dump $array;
293  
294 =head2 dump_unsigned_long
295  
296 C<static method dump_unsigned_long : string ($array : long[]);>
297  
298 Same as the following code using the L<dump operator|SPVM::Document::Language/"dump Operator"> operator, but the elements are displayed as unsigned 64-bit integer.
299  
300 my $ret = dump $array;
301  
302 =head2 dump_unsigned_short
303  
304 C<static method dump_unsigned_short : string ($array : short[]);>
305  
306 Same as the following code using the L<dump operator|SPVM::Document::Language/"dump Operator"> operator, but the elements are displayed as unsigned 16-bit integer.
307  
308 my $ret = dump $array;
309  
310 =head2 equals_byte
311  
312 C<static method equals_byte : int ($array1 : byte[], $array2 : byte[]);>
313  
314 If $array1 is not defined and $array2 is not defined, returns 1.
315  
316 If $array1 is defined and $array2 is not defined, returns 0.
317  
318 If $array1 is not defined, $array2 is defined, returns 0.
319  
320 If $array1 is defined and $array2 is defined and the all elements of $array1 are equal to all elements of $array2, returns 1.
321  
322 Otherwise return 0.
323  
324 =head2 equals_double
325  
326 C<static method equals_double : int ($array1 : double[], $array2 : double[]);>
327  
328 If $array1 is not defined and $array2 is not defined, returns 1.
329  
330 If $array1 is defined and $array2 is not defined, returns 0.
331  
332 If $array1 is not defined, $array2 is defined, returns 0.
333  
334 If $array1 is defined and $array2 is defined and the all elements of $array1 are equal to all elements of $array2, returns 1.
335  
336 Otherwise return 0.
337  
338 =head2 equals_float
339  
340 C<static method equals_float : int ($array1 : float[], $array2 : float[]);>
341  
342 If $array1 is not defined and $array2 is not defined, returns 1.
343  
344 If $array1 is defined and $array2 is not defined, returns 0.
345  
346 If $array1 is not defined, $array2 is defined, returns 0.
347  
348 If $array1 is defined and $array2 is defined and the all elements of $array1 are equal to all elements of $array2, returns 1.
349  
350 Otherwise return 0.
351  
352 =head2 equals_int
353  
354 C<static method equals_int : int ($array1 : int[], $array2 : int[]);>
355  
356 If $array1 is not defined and $array2 is not defined, returns 1.
357  
358 If $array1 is defined and $array2 is not defined, returns 0.
359  
360 If $array1 is not defined, $array2 is defined, returns 0.
361  
362 If $array1 is defined and $array2 is defined and the all elements of $array1 are equal to all elements of $array2, returns 1.
363  
364 Otherwise return 0.
365  
366 =head2 equals_long
367  
368 C<static method equals_long : int ($array1 : long[], $array2 : long[]);>
369  
370 If $array1 is not defined and $array2 is not defined, returns 1.
371  
372 If $array1 is defined and $array2 is not defined, returns 0.
373  
374 If $array1 is not defined, $array2 is defined, returns 0.
375  
376 If $array1 is defined and $array2 is defined and the all elements of $array1 are equal to all elements of $array2, returns 1.
377  
378 Otherwise return 0.
379  
380 =head2 equals_object
381  
382 C<static method static method equals_object : int ($array1 : object[], $array2 : object[], $equality_checker : L<EqualityChecker|SPVM::EqualityChecker>);>
383  
384 If $array1 is not defined and $array2 is not defined, returns 1.
385  
386 If $array1 is defined and $array2 is not defined, returns 0.
387  
388 If $array1 is not defined, $array2 is defined, returns 0.
389  
390 If $array1 is defined and $array2 is defined and the all elements of $array1 are equal to all elements of $array2 using the equality checker, returns 1.
391  
392 The equality checker is not defined, the address is used to check the equality.
393  
394 Otherwise return 0.
395  
396 =head2 equals_object_address
397  
398 C<static method equals_object_address : int ($array1 : object[], $array2 : object[]);>
399  
400 The alias for the following code using L</"equals_object">.
401  
402 my $ret = &equals_object($array1, $array2, undef);
403  
404 =head2 equals_short
405  
406 C<static method equals_short : int ($array1 : short[], $array2 : short[]);>
407  
408 If $array1 is not defined and $array2 is not defined, returns 1.
409  
410 If $array1 is defined and $array2 is not defined, returns 0.
411  
412 If $array1 is not defined, $array2 is defined, returns 0.
413  
414 If $array1 is defined and $array2 is defined and the all elements of $array1 are equal to all elements of $array2, returns 1.
415  
416 Otherwise return 0.
417  
418 =head2 equals_string
419  
420 C<static method equals_string : int ($array1 : string[], $array2 : string[]);>
421  
422 If $array1 is not defined and $array2 is not defined, returns 1.
423  
424 If $array1 is defined and $array2 is not defined, returns 0.
425  
426 If $array1 is not defined, $array2 is defined, returns 0.
427  
428 If $array1 is defined and $array2 is defined and the all elements of $array1 are equal to all elements of $array2 using the C<eq> operator, returns 1.
429  
430 Otherwise return 0.
431  
432 =head2 equals_string_address
433  
434 C<static method equals_string_address : int ($array1 : string[], $array2 : string[]);>
435  
436 The alias for the following code using L</"equals_object_address">.
437  
438 my $ret = &equals_object_address($array1, $array2);
439  
440 =head2 memcpy_byte
441  
442 C<static method memcpy_byte : void ($dest : byte[], $dest_offset : int, $source : byte[], $source_offset : int, $length : int);>
443  
444 Copy the range of the elements of $source C<byte> array to the range of the elements of $dest C<byte> array.
445  
446 The range of the elements of $source array is from $offset to the position proceeded by $length of the source.
447  
448 The range of the elements of $dest array is from $dest_offset to $dest_offset + $length.
449  
450 If the range of the elements of $source array and the range of the elements of $dest array overlap, the result is B<not> guaranteed.
451  
452 Exceptions:
453  
454 $dest must be defined. Otherwise an exception is thrown.
455  
456 $source must be defined. Otherwise an exception is thrown.
457  
458 $length must be greater than or equal to 0. Otherwise an exception is thrown.
459  
460 $dest_offset must be greater than or equal to 0. Otherwise an exception is thrown.
461  
462 $source_offset must be greater than or equal to 0. Otherwise an exception is thrown.
463  
464 $dest_offset + $length must be less than or equal to the length of $dest. Otherwise an exception is thrown.
465  
466 $source_offset + $length must be less than or equal to the length of $source. Otherwise an exception is thrown.
467  
468 =head2 memcpy_double
469
470 C<static method memcpy_double : void ($dest : double[], $dest_offset : int, $source : double[], $source_offset : int, $length : int);>
471  
472 Copy the range of the elements of $source C<double> array to the range of the elements of $dest C<double> array.
473  
474 The range of the elements of $source array is from $offset to the position proceeded by $length of the source.
475  
476 The range of the elements of $dest array is from $dest_offset to $dest_offset + $length.
477  
478 If the range of the elements of $source array and the range of the elements of $dest array overlap, the result is B<not> guaranteed.
479  
480 Exceptions:
481  
482 $dest must be defined. Otherwise an exception is thrown.
483  
484 $source must be defined. Otherwise an exception is thrown.
485  
486 $length must be greater than or equal to 0. Otherwise an exception is thrown.
487  
488 $dest_offset must be greater than or equal to 0. Otherwise an exception is thrown.
489  
490 $source_offset must be greater than or equal to 0. Otherwise an exception is thrown.
491  
492 $dest_offset + $length must be less than or equal to the length of $dest. Otherwise an exception is thrown.
493  
494 $source_offset + $length must be less than or equal to the length of $source. Otherwise an exception is thrown.
495  
496 =head2 memcpy_float
497
498 C<static method memcpy_float : void ($dest : float[], $dest_offset : int, $source : float[], $source_offset : int, $length : int);>
499  
500 Copy the range of the elements of $source C<float> array to the range of the elements of $dest C<float> array.
501  
502 The range of the elements of $source array is from $offset to the position proceeded by $length of the source.
503  
504 The range of the elements of $dest array is from $dest_offset to $dest_offset + $length.
505  
506 If the range of the elements of $source array and the range of the elements of $dest array overlap, the result is B<not> guaranteed.
507  
508 Exceptions:
509  
510 $dest must be defined. Otherwise an exception is thrown.
511  
512 $source must be defined. Otherwise an exception is thrown.
513  
514 $length must be greater than or equal to 0. Otherwise an exception is thrown.
515  
516 $dest_offset must be greater than or equal to 0. Otherwise an exception is thrown.
517  
518 $source_offset must be greater than or equal to 0. Otherwise an exception is thrown.
519  
520 $dest_offset + $length must be less than or equal to the length of $dest. Otherwise an exception is thrown.
521  
522 $source_offset + $length must be less than or equal to the length of $source. Otherwise an exception is thrown.
523  
524 =head2 memcpy_int
525
526 C<static method memcpy_int : void ($dest : int[], $dest_offset : int, $source : int[], $source_offset : int, $length : int);>
527  
528 Copy the range of the elements of $source C<int> array to the range of the elements of $dest C<int> array.
529  
530 The range of the elements of $source array is from $offset to the position proceeded by $length of the source.
531  
532 The range of the elements of $dest array is from $dest_offset to $dest_offset + $length.
533  
534 If the range of the elements of $source array and the range of the elements of $dest array overlap, the result is B<not> guaranteed.
535  
536 Exceptions:
537  
538 $dest must be defined. Otherwise an exception is thrown.
539  
540 $source must be defined. Otherwise an exception is thrown.
541  
542 $length must be greater than or equal to 0. Otherwise an exception is thrown.
543  
544 $dest_offset must be greater than or equal to 0. Otherwise an exception is thrown.
545  
546 $source_offset must be greater than or equal to 0. Otherwise an exception is thrown.
547  
548 $dest_offset + $length must be less than or equal to the length of $dest. Otherwise an exception is thrown.
549  
550 $source_offset + $length must be less than or equal to the length of $source. Otherwise an exception is thrown.
551  
552 =head2 memcpy_long
553
554 C<static method memcpy_long : void ($dest : long[], $dest_offset : int, $source : long[], $source_offset : int, $length : int);>
555  
556 Copy the range of the elements of $source C<long> array to the range of the elements of $dest C<long> array.
557  
558 The range of the elements of $source array is from $offset to the position proceeded by $length of the source.
559  
560 The range of the elements of $dest array is from $dest_offset to $dest_offset + $length.
561  
562 If the range of the elements of $source array and the range of the elements of $dest array overlap, the result is B<not> guaranteed.
563  
564 Exceptions:
565  
566 $dest must be defined. Otherwise an exception is thrown.
567  
568 $source must be defined. Otherwise an exception is thrown.
569  
570 $length must be greater than or equal to 0. Otherwise an exception is thrown.
571  
572 $dest_offset must be greater than or equal to 0. Otherwise an exception is thrown.
573  
574 $source_offset must be greater than or equal to 0. Otherwise an exception is thrown.
575  
576 $dest_offset + $length must be less than or equal to the length of $dest. Otherwise an exception is thrown.
577  
578 $source_offset + $length must be less than or equal to the length of $source. Otherwise an exception is thrown.
579  
580 =head2 memcpy_object_address
581  
582 C<static method memcpy_object_address : void ($dest : object[], $dest_offset : int, $source : object[], $source_offset : int, $length : int);>
583  
584 Copy the range of the elements of $source object array to the range of the elements of $dest object array.
585  
586 Each address is copied.
587  
588 The range of the elements of $source array is from $offset to the position proceeded by $length of the source.
589  
590 The range of the elements of $dest array is from $dest_offset to $dest_offset + $length.
591  
592 If the range of the elements of $source array and the range of the elements of $dest array overlap, the result is B<not> guaranteed.
593  
594 Exceptions:
595  
596 $dest must be defined. Otherwise an exception is thrown.
597  
598 $source must be defined. Otherwise an exception is thrown.
599  
600 $length must be greater than or equal to 0. Otherwise an exception is thrown.
601  
602 $dest_offset must be greater than or equal to 0. Otherwise an exception is thrown.
603  
604 $source_offset must be greater than or equal to 0. Otherwise an exception is thrown.
605  
606 $dest_offset + $length must be less than or equal to the length of $dest. Otherwise an exception is thrown.
607  
608 $source_offset + $length must be less than or equal to the length of $source. Otherwise an exception is thrown.
609  
610 =head2 memcpy_short
611  
612 C<static method memcpy_short : void ($dest : short[], $dest_offset : int, $source : short[], $source_offset : int, $length : int);>
613  
614 Copy the range of the elements of $source C<short> array to the range of the elements of $dest C<short> array.
615  
616 The range of the elements of $source array is from $offset to the position proceeded by $length of the source.
617  
618 The range of the elements of $dest array is from $dest_offset to $dest_offset + $length.
619  
620 If the range of the elements of $source array and the range of the elements of $dest array overlap, the result is B<not> guaranteed.
621  
622 Exceptions:
623  
624 $dest must be defined. Otherwise an exception is thrown.
625  
626 $source must be defined. Otherwise an exception is thrown.
627  
628 $length must be greater than or equal to 0. Otherwise an exception is thrown.
629  
630 $dest_offset must be greater than or equal to 0. Otherwise an exception is thrown.
631  
632 $source_offset must be greater than or equal to 0. Otherwise an exception is thrown.
633  
634 $dest_offset + $length must be less than or equal to the length of $dest. Otherwise an exception is thrown.
635  
636 $source_offset + $length must be less than or equal to the length of $source. Otherwise an exception is thrown.
637  
638 =head2 memcpy_string_address
639  
640 C<static method memcpy_string_address : void ($dest : string[], $dest_offset : int, $source : string[], $source_offset : int, $length : int);>
641  
642 The alias for L</"memcpy_object_address">.
643  
644 =head2 memmove_byte
645  
646 C<static method memmove_byte : void ($dest : byte[], $dest_offset : int, $source : byte[], $source_offset : int, $length : int);>
647  
648 The same as L</"memcpy_byte">, but even if the range of the source and the range of the destination overlap, the result is guaranteed.
649  
650 =head2 memmove_double
651
652 C<static method memmove_double : void ($dest : double[], $dest_offset : int, $source : double[], $source_offset : int, $length : int);>
653  
654 The same as L</"memcpy_double">, but even if the range of the source and the range of the destination overlap, the result is guaranteed.
655  
656 =head2 memmove_float
657
658 C<static method memmove_float : void ($dest : float[], $dest_offset : int, $source : float[], $source_offset : int, $length : int);>
659  
660 The same as L</"memcpy_float">, but even if the range of the source and the range of the destination overlap, the result is guaranteed.
661  
662 =head2 memmove_int
663
664 C<static method memmove_int : void ($dest : int[], $dest_offset : int, $source : int[], $source_offset : int, $length : int);>
665  
666 The same as L</"memcpy_int">, but even if the range of the source and the range of the destination overlap, the result is guaranteed.
667  
668 =head2 memmove_long
669
670 C<static method memmove_long : void ($dest : long[], $dest_offset : int, $source : long[], $source_offset : int, $length : int);>
671  
672 The same as L</"memcpy_long">, but even if the range of the source and the range of the destination overlap, the result is guaranteed.
673  
674 =head2 memmove_object_address
675  
676 C<static method memmove_object_address : void ($dest : object[], $dest_offset : int, $source : object[], $source_offset : int, $length : int);>
677  
678 The same as L</"memcpy_object_address">, but even if the range of the source and the range of the destination overlap, the result is guaranteed.
679  
680 =head2 memmove_short
681  
682 C<static method memmove_short : void ($dest : short[], $dest_offset : int, $source : short[], $source_offset : int, $length : int);>
683  
684 The same as L</"memcpy_short">, but even if the range of the source and the range of the destination overlap, the result is guaranteed.
685  
686 =head2 memmove_string_address
687  
688 C<static method memmove_string_address : void ($dest : string[], $dest_offset : int, $source : string[], $source_offset : int, $length : int);>
689  
690 The same as the following code using L</"memmove_object_address">.
691  
692 &memmove_object_address($dest, $dest_offset, $source, $source_offset, $length);
693  
694 =head2 memset_byte
695  
696 C<static method memset_byte : void ($array : byte[], $element : int, $offset : int = 0, $length : int = -1);>
697  
698 Set the range of the elements of the C<byte> array to $element.
699  
700 The range of the elements of $array is from $offset to the position proceeded by $length.
701  
702 If $length is less than 0, it is the length of $array minus $offset.
703  
704 Exceptions:
705  
706 $array must be defined.
707  
708 $offset must be greater than or equal to 0. Otherwise an exception is thrown.
709  
710 $offset + $length must be less than or equal to the length of $array. Otherwise an exception is thrown.
711  
712 =head2 memset_double
713  
714 C<static method memset_double : void ($array : double[], $element : double, $offset : int = 0, $length : int = -1);>
715  
716 Set the range of the elements of the C<double> array to $element.
717  
718 The range of the elements of $array is from $offset to the position proceeded by $length.
719  
720 If $length is less than 0, it is the length of $array minus $offset.
721  
722 Exceptions:
723  
724 $array must be defined. Otherwise an exception is thrown.
725  
726 $offset must be greater than or equal to 0. Otherwise an exception is thrown.
727  
728 $offset + $length must be less than or equal to the length of $array. Otherwise an exception is thrown.
729  
730 =head2 memset_float
731  
732 C<static method memset_float : void ($array : float[], $element : float, $offset : int = 0, $length : int = -1);>
733  
734 Set the range of the elements of the C<float> array to $element.
735  
736 The range of the elements of $array is from $offset to the position proceeded by $length.
737  
738 If $length is less than 0, it is the length of $array minus $offset.
739  
740 Exceptions:
741  
742 $array must be defined. Otherwise an exception is thrown.
743  
744 $offset must be greater than or equal to 0. Otherwise an exception is thrown.
745  
746 $offset + $length must be less than or equal to the length of $array. Otherwise an exception is thrown.
747  
748 =head2 memset_int
749  
750 C<static method memset_int : void ($array : int[], $element : int, $offset : int = 0, $length : int = -1);>
751  
752 Set the range of the elements of the C<int> array to $element.
753  
754 The range of the elements of $array is from $offset to the position proceeded by $length.
755  
756 If $length is less than 0, it is the length of $array minus $offset.
757  
758 Exceptions:
759  
760 $array must be defined. Otherwise an exception is thrown.
761  
762 $offset must be greater than or equal to 0. Otherwise an exception is thrown.
763  
764 $offset + $length must be less than or equal to the length of $array. Otherwise an exception is thrown.
765  
766 =head2 memset_long
767  
768 C<static method memset_long : void ($array : long[], $element : long, $offset : int = 0, $length : int = -1);>
769  
770 Set the range of the elements of the C<long> array to $element.
771  
772 The range of the elements of $array is from $offset to the position proceeded by $length.
773  
774 If $length is less than 0, it is the length of $array minus $offset.
775  
776 Exceptions:
777  
778 $array must be defined. Otherwise an exception is thrown.
779  
780 $offset must be greater than or equal to 0. Otherwise an exception is thrown.
781  
782 $offset + $length must be less than or equal to the length of $array. Otherwise an exception is thrown.
783  
784 =head2 memset_object
785  
786 C<static method memset_object : void ($array : object[], $element : object, $offset : int = 0, $length : int = -1);>
787  
788 Set the range of the elements of the object $array to $element.
789  
790 The range of the elements of $array is from $offset to the position proceeded by $length.
791  
792 If $length is less than 0, it is the length of $array minus $offset.
793  
794 Exceptions:
795  
796 $array must be defined. Otherwise an exception is thrown.
797  
798 $offset must be greater than or equal to 0. Otherwise an exception is thrown.
799  
800 $offset + $length must be less than or equal to the length of $array. Otherwise an exception is thrown.
801  
802 =head2 memset_short
803  
804 C<static method memset_short : void ($array : short[], $element : int, $offset : int = 0, $length : int = -1);>
805  
806 Set the range of the elements of the C<short> $array to $element.
807  
808 The range of the elements of $array is from $offset to the position proceeded by $length.
809  
810 If $length is less than 0, it is the length of $array minus $offset.
811  
812 Exceptions:
813  
814 $array must be defined. Otherwise an exception is thrown.
815  
816 $offset must be greater than or equal to 0. Otherwise an exception is thrown.
817  
818 $offset + $length must be less than or equal to the length of $array. Otherwise an exception is thrown.
819  
820 =head2 memset_string
821  
822 C<static method memset_string : void ($array : string[], $element : string, $offset : int = 0, $length : int = -1);>
823  
824 The alias for the following code using L</"memset_object">.
825  
826 &memset_object($dest, $element, $dest_offset, $length);
827  
828 =head2 merge_byte
829  
830 C<static method merge_byte : byte[] ($array1 : byte[], $array2 : byte[]);>
831  
832 Creates a new array by merging the array $array1 and the array $array2, and returns it.
833  
834 Exceptions:
835  
836 \$array1 must be defined. Otherwise an exception is thrown.
837  
838 \$array2 must be defined. Otherwise an exception is thrown.
839  
840 =head2 merge_short
841  
842 C<static method merge_short : short[] ($array1 : short[], $array2 : short[]);>
843  
844 Creates a new array by merging the array $array1 and the array $array2, and returns it.
845  
846 Exceptions:
847  
848 \$array1 must be defined. Otherwise an exception is thrown.
849  
850 \$array2 must be defined. Otherwise an exception is thrown.
851  
852 =head2 merge_int
853  
854 C<static method merge_int : int[] ($array1 : int[], $array2 : int[]);>
855  
856 Creates a new array by merging the array $array1 and the array $array2, and returns it.
857  
858 Exceptions:
859  
860 \$array1 must be defined. Otherwise an exception is thrown.
861  
862 \$array2 must be defined. Otherwise an exception is thrown.
863  
864 =head2 merge_long
865  
866 C<static method merge_long : long[] ($array1 : long[], $array2 : long[]);>
867  
868 Creates a new array by merging the array $array1 and the array $array2, and returns it.
869  
870 Exceptions:
871  
872 \$array1 must be defined. Otherwise an exception is thrown.
873  
874 \$array2 must be defined. Otherwise an exception is thrown.
875  
876 =head2 merge_float
877  
878 C<static method merge_float : float[] ($array1 : float[], $array2 : float[]);>
879  
880 Creates a new array by merging the array $array1 and the array $array2, and returns it.
881  
882 Exceptions:
883  
884 \$array1 must be defined. Otherwise an exception is thrown.
885  
886 \$array2 must be defined. Otherwise an exception is thrown.
887  
888 =head2 merge_double
889  
890 C<static method merge_double : double[] ($array1 : double[], $array2 : double[]);>
891  
892 Creates a new array by merging the array $array1 and the array $array2, and returns it.
893  
894 Exceptions:
895  
896 \$array1 must be defined. Otherwise an exception is thrown.
897  
898 \$array2 must be defined. Otherwise an exception is thrown.
899  
900 =head2 merge_string
901  
902 C<static method merge_string : string[] ($array1 : string[], $array2 : string[]);>
903  
904 Creates a new array by merging the array $array1 and the array $array2, and returns it.
905  
906 Exceptions:
907  
908 \$array1 must be defined. Otherwise an exception is thrown.
909  
910 \$array2 must be defined. Otherwise an exception is thrown.
911  
912 =head2 merge_object
913  
914 C<static method merge_object : object[] ($array1 : object[], $array2 : object[]);>
915  
916 Creates a new array by merging the array $array1 and the array $array2, and returns it.
917  
918 Exceptions:
919  
920 \$array1 must be defined. Otherwise an exception is thrown.
921  
922 \$array2 must be defined. Otherwise an exception is thrown.
923  
924 =head2 new_proto
925  
926 C<static method new_proto : object[] ($proto_array : object[], $length : int);>
927  
928 Create a new object array as the same type as $proto_array with $length.
929  
930 Exceptions:
931  
932 $prototype array must be defined. Otherwise an exception is thrown.
933  
934 $length must be greater than or equal to 0. Otherwise an exception is thrown.
935  
936 =head2 new_proto_any
937  
938 C<static method new_proto_any : object ($proto_array : object, $length : int);>
939  
940 Same as L</"new_proto"> method, but can give $proto_array of the type of a numeric array or a multi-numeric array and the return type is different.
941  
942 =head2 shuffle_object
943  
944 C<static method shuffle_object : void ($array : object[], $seed_ref : int*);>
945  
946 Shuffles the array $array in-place given the reference to a seed $seed_ref.
947  
948 Exceptions:
949  
950 $array must be defined. Otherwise an exception is thrown.
951  
952 =head2 repeat_string
953  
954 C<static method repeat_string : string[] ($strings : string[], $count : int);>
955  
956 Creates a new array that repeats the string $strings $count times, and returns it.
957  
958 Exceptions:
959  
960 $strings must be defined. Otherwise an exception is thrown.
961  
962 $count must be greater than or equal to 0. Otherwise an exception is thrown.
963  
964 =head2 copy_object_with_proto
965  
966 C<static method copy_object_with_proto : object[] ($array : object[], $proto : object[], $cloner : L<Cloner|SPVM::Cloner> = undef, $offset : int = 0, $length : int = -1);>
967  
968 The same as L</"copy_object">, but can give the prototype array $proto for the copied array.
969  
970 =head2 copy_object_address_with_proto
971  
972 C<static method copy_object_address_with_proto : object[] ($array : object[], $proto : object[], $offset : int = 0, $length : int = -1);>
973  
974 The same as L</"copy_object_address">, but can give the prototype array $proto for the copied array.
975  
976 =head2 to_object_array_byte
977  
978 C<static method to_object_array_byte : L<Byte|SPVM::Byte>[] ($array : byte[]);>
979  
980 Creates a new L<Byte|SPVM::Byte> array with the same length as the byte array $array, copies the elements in $array to it, and returns it.
981  
982 Exceptions:
983  
984 The array $array must be defined. Otherwise, an exception is thrown.
985  
986 =head2 to_object_array_short
987  
988 C<static method to_object_array_short : L<Short|SPVM::Short>[] ($array : short[]);>
989  
990 Creates a new L<Short|SPVM::Short> array with the same length as the short array $array, copies the elements in $array to it, and returns it.
991  
992 Exceptions:
993  
994 The array $array must be defined. Otherwise, an exception is thrown.
995  
996 =head2 to_object_array_int
997  
998 C<static method to_object_array_int : L<Int|SPVM::Int>[] ($array : int[]);>
999  
1000 Creates a new L<Int|SPVM::Int> array with the same length as the int array $array, copies the elements in $array to it, and returns it.
1001  
1002 Exceptions:
1003  
1004 The array $array must be defined. Otherwise, an exception is thrown.
1005  
1006 =head2 to_object_array_long
1007  
1008 C<static method to_object_array_long : L<Long|SPVM::Long>[] ($array : long[]);>
1009  
1010 Creates a new L<Long|SPVM::Long> array with the same length as the long array $array, copies the elements in $array to it, and returns it.
1011  
1012 Exceptions:
1013  
1014 The array $array must be defined. Otherwise, an exception is thrown.
1015  
1016 =head2 to_object_array_float
1017  
1018 C<static method to_object_array_float : L<Float|SPVM::Float>[] ($array : float[]);>
1019  
1020 Creates a new L<Float|SPVM::Float> array with the same length as the float array $array, copies the elements in $array to it, and returns it.
1021  
1022 =head2 to_object_array_double
1023  
1024 C<static method to_object_array_double : L<Double|SPVM::Double>[] ($array : double[]);>
1025  
1026 Creates a new L<Double|SPVM::Double> array with the same length as the double array $array, copies the elements in $array to it, and returns it.
1027  
1028 Exceptions:
1029  
1030 The array $array must be defined. Otherwise, an exception is thrown.
1031  
1032 =head2 to_array_byte
1033  
1034 C<static method to_array_byte : byte[] ($object_array : L<Byte|SPVM::Byte>[]);>
1035  
1036 Creates a new byte array with the same length as L<Byte|SPVM::Byte> array $object_array, copies the elements in $array to it, and returns it.
1037  
1038 Exceptions:
1039  
1040 The array $array must be defined. Otherwise, an exception is thrown.
1041  
1042 =head2 to_array_short
1043  
1044 C<static method to_array_short : short[] ($object_array : L<Short|SPVM::Short>[]);>
1045  
1046 Creates a new short array with the same length as L<Short|SPVM::Short>> array $object_array, copies the elements in $array to it, and returns it.
1047  
1048 Exceptions:
1049  
1050 The array $object_array must be defined. Otherwise, an exception is thrown.
1051  
1052 =head2 to_array_int
1053  
1054 C<static method to_array_int : int[] ($object_array : L<Int|SPVM::Int>[]>);>
1055  
1056 Creates a new int array with the same length as L<Int|SPVM::Int> array $object_array, copies the elements in $array to it, and returns it.
1057  
1058 Exceptions:
1059  
1060 The array $object_array must be defined. Otherwise, an exception is thrown.
1061  
1062 =head2 to_array_long
1063  
1064 C<static method to_array_long : long[] ($object_array : L<Long|SPVM::Long>[]);>
1065  
1066 Creates a new long array with the same length as L<Long|SPVM::Long> array $object_array, copies the elements in $array to it, and returns it.
1067  
1068 Exceptions:
1069  
1070 The array $object_array must be defined. Otherwise, an exception is thrown.
1071  
1072 =head2 to_array_float
1073  
1074 C<static method to_array_float : float[] ($object_array : L<Float|SPVM::Float>[]);>
1075  
1076 Creates a new float array with the same length as L<Float|SPVM::Float> array $object_array, copies the elements in $array to it, and returns it.
1077  
1078 Exceptions:
1079  
1080 The array $object_array must be defined. Otherwise, an exception is thrown.
1081  
1082 =head2 to_array_double
1083  
1084 C<static method to_array_double : double[] ($object_array : L<Double|SPVM::Double>[]);>
1085  
1086 Creates a new double[ array with the same length as L<Double|SPVM::Double> array $object_array, copies the elements in $array to it, and returns it.
1087  
1088 Exceptions:
1089  
1090 The array $object_array must be defined. Otherwise, an exception is thrown.
1091  
1092 =head2 new_array_proto_element
1093  
1094 C<static method new_array_proto_element : object[] ($proto_element : object, $length : int);>
1095  
1096 Create a new object array of the type when the prototype element $proto_element are arrayed with the length $length.
1097  
1098 Exceptions:
1099  
1100 The prototype element $proto_element must be defined. Otherwise an exception is thrown.
1101  
1102 The length $length must be greater than or equal to 0. Otherwise an exception is thrown.
1103  
1104 =head2 equals
1105  
1106 C<static method equals : int ($array1 : object, $array2 : object, $shallow : int = 0);>
1107  
1108 Checks if the array $array1 and the array $array2 are equal.
1109  
1110 The type of $array1 and $array2 must be a numeric array type, a multi-numeric array type, string array type, or an object array type.
1111  
1112 Implementation:
1113  
1114 If $array1 is not defined and $array2 is not defined, returns 1.
1115  
1116 If $array1 is defined and $array2 is not defined, returns 0.
1117  
1118 If $array1 is not defined, $array2 is defined, returns 0.
1119  
1120 If the type of $array1 is not equal to the type of $array2, returns 0.
1121  
1122 If the type of $array1 is a numeric array type or a muti-numeric type and every element of $array1 are equal to the corresponding index of element of $array2, returns 1, otherwise returns 0.
1123  
1124 If the type of $array1 is string array type and $shallow is a false value, returns the return value of L</"equals_string"> method.
1125  
1126 If the type of $array1 is string array type and $shallow is a true value, returns the return value of L</"equals_string_address"> method.
1127  
1128 If the type of $array1 is an object array type and $shallow is a false value, returns the return value of L</"equals_object"> method given L<EqualityChecker#default_equality_checker|SPVM::EqualityChecker#/"default_equality_checker">.
1129  
1130 If the type of $array1 is an object array type and $shallow is a true value, returns the return value of L</"equals_object_address"> method.
1131  
1132 Exceptions:
1133  
1134 The type of the array $array1 must be an array type. Otherwise, an exception is thrown.
1135  
1136 The type of the array $array2 must be an array type. Otherwise, an exception is thrown.
1137  
1138 The type of the $array must be a numeric array type, a multi-numeric array type, string array type, or an object array type. Otherwise, an exception is thrown.
1139  
1140 =head2 copy_any_numeric
1141  
1142 C<static method copy_any_numeric : object ($array : object, $offset : int = 0, $length : int = -1);>
1143  
1144 Create a new array of the same type of $array with $length, and copy the elements from $offset to the position proceeded by $length to the created array.
1145  
1146 If $length is less than 0, it is the length of $array minus $offset.
1147  
1148 Exceptions:
1149  
1150 $array must be defined. Otherwise an exception is thrown.
1151  
1152 The type of the array $array must be a numeric array type or a multi-numeric type.
1153  
1154 $offset must be greater than or equal to 0. Otherwise an exception is thrown.
1155  
1156 $offset + $length must be less than or equal to the length of $array. Otherwise an exception is thrown.
1157  
1158 =head2 shuffle_any_numeric
1159  
1160 C<static method shuffle_any_numeric : void ($array : object, $seed_ref : int*);>
1161  
1162 Shuffles the array $array in-place given the reference to a seed $seed_ref.
1163  
1164 The type of $array must be a numeric type or a multi-numeric type.
1165  
1166 Exceptions:
1167  
1168 $array must be defined. Otherwise an exception is thrown.
1169  
1170 The type of the array $array must be a numeric type or a multi-numeric type. Otherwise an exception is thrown.
1171  
1172 =head2 shuffle
1173  
1174 C<static method shuffle : void ($array : object, $seed_ref : int*);>
1175  
1176 Shuffles the array $array in-place given the reference to a seed $seed_ref.
1177  
1178 The type of $array must be an object type, a numeric type or a multi-numeric type.
1179  
1180 Exceptions:
1181  
1182 $array must be defined. Otherwise an exception is thrown.
1183  
1184 The type of $array must be an object type, a numeric type or a multi-numeric type.
1185  
1186 =head2 repeat
1187  
1188 C<static method repeat : object ($array : obejct, $count : int);>
1189  
1190 Retruns a new array that repeats the array $array $count times.
1191  
1192 Exceptions:
1193  
1194 The array $array must be defined. Otherwise an exception is thrown.
1195  
1196 The type of the array $array must be an array type. Otherwise an exception is thrown.
1197  
1198 The repeat count $count must be a non-negative integer. Otherwise an exception is thrown.
1199  
1200 =head2 merge
1201  
1202 C<static method merge : byte[]|short[]|int[]|long[]|float[]|double[]|string[]|object[] ($array1 : byte[]|short[]|int[]|long[]|float[]|double[]|string[]|object[], $array2 : byte[]|short[]|int[]|long[]|float[]|double[]|string[]|object[]);>
1203  
1204 Creates a new array by merging the array $array1 and the array $array2, and returns it.
1205  
1206 Exceptions:
1207  
1208 $array1 must be defined. Otherwise an exception is thrown.
1209  
1210 $array2 must be defined. Otherwise an exception is thrown.
1211  
1212 The type of $array1 must be the same as the type of $array2. Otherwise an exception is thrown.
1213  
1214 The type of $array1 must be a supported array type. Otherwise an exception is thrown.
1215  
1216 =head2 to_object_array
1217  
1218 C<static method to_object_array : Byte[]|Short[]|Int[]|Long[]|Float[]|Double[] ($array : byte[]|short[]|int[]|long[]|float[]|double[]);>
1219  
1220 Converts a primitive array to an object array, and returns it.
1221  
1222 Each element in the primitive array is boxed into its corresponding wrapper object (e.g., C<byte> to C<Byte>).
1223  
1224 Exceptions:
1225  
1226 $array must be defined. Otherwise an exception is thrown.
1227  
1228 The type of $array must be a numeric array type. Otherwise an exception is thrown.
1229  
1230 =head2 to_array
1231  
1232 C<static method to_array : byte[]|short[]|int[]|long[]|float[]|double[] ($object_array : Byte[]|Short[]|Int[]|Long[]|Float[]|Double[]);>
1233  
1234 Converts an object array to a primitive array, and returns it.
1235  
1236 Each wrapper object in the array is unboxed into its corresponding primitive value (e.g., C<Byte> to C<byte>).
1237  
1238 Exceptions:
1239  
1240 $object_array must be defined. Otherwise an exception is thrown.
1241  
1242 The type of $object_array must be a numeric object array type. Otherwise an exception is thrown.
1243  
1244 =head1 Copyright & License
1245  
1246 Copyright (c) 2023 Yuki Kimoto
1247  
1248 MIT License