1 package org.enhydra.kelp.ant.swing; 2 3 7 import java.net.URL ; 8 9 public class LifoURL { 10 public int currElem; 11 public int maxElemsNum; 12 public URL [] urls; 13 14 public LifoURL(int max) { 15 currElem = 0; 16 if (max > 100) { 17 maxElemsNum = 100; 18 urls = new URL [100]; 19 } else { 20 maxElemsNum = max; 21 urls = new URL [max]; 22 } 23 } 24 25 public void add(URL url) { 26 if (currElem == maxElemsNum) { 27 for (int i = 0; i < maxElemsNum-2; i++) 28 urls[i] = urls[i+1]; 29 currElem--; 30 } 31 urls[currElem++] = url; 32 } 33 34 public URL remove() { 35 if (currElem == 0) 36 return null; 37 return urls[--currElem]; 38 } 39 40 public boolean isEmpty() { 41 if (currElem == 0) 42 return true; 43 return false; 44 } 45 46 } 47 | Popular Tags |