diff options
author | paltherr <paltherr@epfl.ch> | 2003-09-07 10:50:55 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2003-09-07 10:50:55 +0000 |
commit | 7e8533ec4275548c8fe13d78f8872b932a806956 (patch) | |
tree | 4f65e2cde88eebfeed3873fe4409e17d4cab6f05 /sources/scalac/symtab/Symbol.java | |
parent | d107eb40f1372ab1a1b9b26220e55c512d44ecd7 (diff) | |
download | scala-7e8533ec4275548c8fe13d78f8872b932a806956.tar.gz scala-7e8533ec4275548c8fe13d78f8872b932a806956.tar.bz2 scala-7e8533ec4275548c8fe13d78f8872b932a806956.zip |
- Added additional cloneArray methods
Diffstat (limited to 'sources/scalac/symtab/Symbol.java')
-rw-r--r-- | sources/scalac/symtab/Symbol.java | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/sources/scalac/symtab/Symbol.java b/sources/scalac/symtab/Symbol.java index fa595e51ff..3fe0b5f554 100644 --- a/sources/scalac/symtab/Symbol.java +++ b/sources/scalac/symtab/Symbol.java @@ -86,9 +86,35 @@ public abstract class Symbol implements Modifiers, Kinds { /** Returns a shallow copy of the given array. */ public static Symbol[] cloneArray(Symbol[] array) { - if (array.length == 0) return array; - Symbol[] clone = new Symbol[array.length]; - for (int i = 0; i < clone.length; i++) clone[i] = array[i]; + return cloneArray(0, array, 0); + } + + /** + * Returns a shallow copy of the given array prefixed by "prefix" + * null items. + */ + public static Symbol[] cloneArray(int prefix, Symbol[] array) { + return cloneArray(prefix, array, 0); + } + + /** + * Returns a shallow copy of the given array suffixed by "suffix" + * null items. + */ + public static Symbol[] cloneArray(Symbol[] array, int suffix) { + return cloneArray(0, array, suffix); + } + + /** + * Returns a shallow copy of the given array prefixed by "prefix" + * null items and suffixed by "suffix" null items. + */ + public static Symbol[] cloneArray(int prefix, Symbol[] array, int suffix) { + assert prefix >= 0 && suffix >= 0: prefix + " - " + suffix; + int size = prefix + array.length + suffix; + if (size == 0) return EMPTY_ARRAY; + Symbol[] clone = new Symbol[size]; + for (int i = 0; i < array.length; i++) clone[prefix + i] = array[i]; return clone; } |