InputProviderArrayPool.java 572 B

123456789101112131415161718192021
  1. package me.hammerle.snuviscript.code;
  2. import me.hammerle.snuviscript.inputprovider.InputProvider;
  3. public class InputProviderArrayPool {
  4. private final static int POOL_SIZE = 10;
  5. private final static InputProvider[][] IN = new InputProvider[POOL_SIZE][];
  6. static {
  7. for(int i = 0; i < IN.length; i++) {
  8. IN[i] = new InputProvider[i];
  9. }
  10. }
  11. public static InputProvider[] get(int length) {
  12. if(length < 0 || length >= POOL_SIZE) {
  13. return new InputProvider[length];
  14. }
  15. return IN[length];
  16. }
  17. }