L2ObjectSet.java 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.util;
  16. import java.util.Iterator;
  17. import com.l2jserver.Config;
  18. import com.l2jserver.gameserver.model.L2Object;
  19. import com.l2jserver.gameserver.model.actor.L2Playable;
  20. /**
  21. * This class ...
  22. * @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $
  23. * @param <T>
  24. */
  25. public abstract class L2ObjectSet<T extends L2Object> implements Iterable<T>
  26. {
  27. public static L2ObjectSet<L2Object> createL2ObjectSet()
  28. {
  29. switch (Config.SET_TYPE)
  30. {
  31. case WorldObjectSet:
  32. return new WorldObjectSet<>();
  33. default:
  34. return new L2ObjectHashSet<>();
  35. }
  36. }
  37. public static L2ObjectSet<L2Playable> createL2PlayerSet()
  38. {
  39. switch (Config.SET_TYPE)
  40. {
  41. case WorldObjectSet:
  42. return new WorldObjectSet<>();
  43. default:
  44. return new L2ObjectHashSet<>();
  45. }
  46. }
  47. public abstract int size();
  48. public abstract boolean isEmpty();
  49. public abstract void clear();
  50. public abstract void put(T obj);
  51. public abstract void remove(T obj);
  52. public abstract boolean contains(T obj);
  53. @Override
  54. public abstract Iterator<T> iterator();
  55. }