WorldObjectSet.java 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 java.util.Map;
  18. import javolution.util.FastMap;
  19. import com.l2jserver.gameserver.model.L2Object;
  20. /**
  21. * This class ...
  22. * @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $
  23. * @param <T>
  24. */
  25. public class WorldObjectSet<T extends L2Object> extends L2ObjectSet<T>
  26. {
  27. private final Map<Integer, T> _objectMap;
  28. public WorldObjectSet()
  29. {
  30. _objectMap = new FastMap<Integer, T>().shared();
  31. }
  32. @Override
  33. public int size()
  34. {
  35. return _objectMap.size();
  36. }
  37. @Override
  38. public boolean isEmpty()
  39. {
  40. return _objectMap.isEmpty();
  41. }
  42. @Override
  43. public void clear()
  44. {
  45. _objectMap.clear();
  46. }
  47. @Override
  48. public void put(T obj)
  49. {
  50. _objectMap.put(obj.getObjectId(), obj);
  51. }
  52. @Override
  53. public void remove(T obj)
  54. {
  55. _objectMap.remove(obj.getObjectId());
  56. }
  57. @Override
  58. public boolean contains(T obj)
  59. {
  60. return _objectMap.containsKey(obj.getObjectId());
  61. }
  62. @Override
  63. public Iterator<T> iterator()
  64. {
  65. return _objectMap.values().iterator();
  66. }
  67. }