MCPcopy Create free account
hub / github.com/apache/commons-lang / ArrayFill

Class ArrayFill

src/main/java/org/apache/commons/lang3/ArrayFill.java:30–275  ·  view source on GitHub ↗

Fills and returns arrays in the fluent style. @since 3.14.0

Source from the content-addressed store, hash-verified

28 * @since 3.14.0
29 */
30public final class ArrayFill {
31
32 /**
33 * Fills and returns the given array, assigning {@code 0} to each element of the array.
34 * <pre>
35 * ArrayFill.fill(a, (byte) 0);
36 * </pre>
37 *
38 * @param a the array to fill (may be null).
39 * @return the given array.
40 * @see Arrays#fill(byte[],byte)
41 * @see ArrayFill#fill(byte[],byte)
42 * @since 3.21.0
43 */
44 public static byte[] clear(final byte[] a) {
45 return fill(a, (byte) 0);
46 }
47
48 /**
49 * Fills and returns the given array, assigning {@code '\0'} to each element of the array.
50 * <p>
51 * Equivalent to:
52 * </p>
53 * <pre>
54 * ArrayFill.fill(a, '\0'); // and not '0'!
55 * </pre>
56 *
57 * @param a the array to fill (may be null).
58 * @return the given array.
59 * @see Arrays#fill(char[],char)
60 * @see ArrayFill#fill(char[],char)
61 * @see CharUtils#NUL
62 * @since 3.21.0
63 */
64 public static char[] clear(final char[] a) {
65 return fill(a, CharUtils.NUL); // and not '0'!
66 }
67
68 /**
69 * Fills and returns the given array, assigning {@code '\0'} to each element of the array.
70 * <p>
71 * Equivalent to:
72 * </p>
73 * <pre>
74 * ArrayFill.fill(a, fromIndex, toIndex, '\0'); // and not '0'!
75 * </pre>
76 *
77 * @param a the array to fill (may be null).
78 * @param fromIndex the index of the first element (inclusive) to be filled with {@code '\0'}.
79 * @param toIndex the index of the last element (exclusive) to be filled with {@code '\0'}.
80 * @return the given array.
81 * @see Arrays#fill(char[], int, int, char)
82 * @since 3.21.0
83 */
84 public static char[] clear(char[] a, int fromIndex, int toIndex) {
85 return fill(a, fromIndex, toIndex, CharUtils.NUL);
86 }
87

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…