1 7 package org.ejtools.util; 8 9 10 16 public class KeyLimitedStack extends LimitedStack 17 { 18 19 public KeyLimitedStack() 20 { 21 super(); 22 } 23 24 25 30 public KeyLimitedStack(int size) 31 { 32 super(size); 33 } 34 35 36 42 public Object push(Object item) 43 { 44 if (this.contains(item)) 46 { 47 this.remove(this.indexOf(item)); 48 } 49 else 50 { 51 if (this.size() >= this.maximumSize) 53 { 54 this.remove(0); 55 } 56 } 57 58 return super.push(item); 60 } 61 } 62 | Popular Tags |