From 8e33cc2cd7f540d5f0b967cf176a9ae77b3a72f0 Mon Sep 17 00:00:00 2001 From: "ray.j.greenwell" Date: Tue, 14 Sep 2010 00:40:05 +0000 Subject: [PATCH] Shareable references to common 0-length arrays. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2883 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../java/com/samskivert/util/ArrayUtil.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/java/com/samskivert/util/ArrayUtil.java b/src/main/java/com/samskivert/util/ArrayUtil.java index 031d3cad..978b2d89 100644 --- a/src/main/java/com/samskivert/util/ArrayUtil.java +++ b/src/main/java/com/samskivert/util/ArrayUtil.java @@ -31,6 +31,30 @@ import java.util.Random; */ public class ArrayUtil { + /** An empty (and thus immutable) int[] that can be shared by anyone. */ + public static final int[] EMPTY_INT = new int[0]; + + /** An empty (and thus immutable) byte[] that can be shared by anyone. */ + public static final byte[] EMPTY_BYTE = new byte[0]; + + /** An empty (and thus immutable) short[] that can be shared by anyone. */ + public static final short[] EMPTY_SHORT = new short[0]; + + /** An empty (and thus immutable) float[] that can be shared by anyone. */ + public static final float[] EMPTY_FLOAT = new float[0]; + + /** An empty (and thus immutable) double[] that can be shared by anyone. */ + public static final double[] EMPTY_DOUBLE = new double[0]; + + /** An empty (and thus immutable) long[] that can be shared by anyone. */ + public static final long[] EMPTY_LONG = new long[0]; + + /** An empty (and thus immutable) Object[] that can be shared by anyone. */ + public static final Object[] EMPTY_OBJECT = new Object[0]; + + /** An empty (and thus immutable) String[] that can be shared by anyone. */ + public static final String[] EMPTY_STRING = new String[0]; + /** * Looks for an element that tests true for Object equality with the supplied value and * returns its index in the array.