WorldObjectSet.java 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * $Header: WorldObjectSet.java, 22/07/2005 14:11:29 luisantonioa Exp $
  3. *
  4. * $Author: luisantonioa $
  5. * $Date: 22/07/2005 14:11:29 $
  6. * $Revision: 1 $
  7. * $Log: WorldObjectSet.java,v $
  8. * Revision 1 22/07/2005 14:11:29 luisantonioa
  9. * Added copyright notice
  10. *
  11. *
  12. * This program is free software: you can redistribute it and/or modify it under
  13. * the terms of the GNU General Public License as published by the Free Software
  14. * Foundation, either version 3 of the License, or (at your option) any later
  15. * version.
  16. *
  17. * This program is distributed in the hope that it will be useful, but WITHOUT
  18. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  19. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  20. * details.
  21. *
  22. * You should have received a copy of the GNU General Public License along with
  23. * this program. If not, see <http://www.gnu.org/licenses/>.
  24. */
  25. package com.l2jserver.gameserver.util;
  26. import java.util.Iterator;
  27. import java.util.Map;
  28. import javolution.util.FastMap;
  29. import com.l2jserver.gameserver.model.L2Object;
  30. /**
  31. * This class ...
  32. *
  33. * @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $
  34. * @param <T>
  35. */
  36. public class WorldObjectSet<T extends L2Object> extends L2ObjectSet<T>
  37. {
  38. private Map<Integer, T> _objectMap;
  39. public WorldObjectSet()
  40. {
  41. _objectMap = new FastMap<Integer, T>().shared();
  42. }
  43. /* (non-Javadoc)
  44. * @see com.l2jserver.util.L2ObjectSet#size()
  45. */
  46. @Override
  47. public int size()
  48. {
  49. return _objectMap.size();
  50. }
  51. /* (non-Javadoc)
  52. * @see com.l2jserver.util.L2ObjectSet#isEmpty()
  53. */
  54. @Override
  55. public boolean isEmpty()
  56. {
  57. return _objectMap.isEmpty();
  58. }
  59. /* (non-Javadoc)
  60. * @see com.l2jserver.util.L2ObjectSet#clear()
  61. */
  62. @Override
  63. public void clear()
  64. {
  65. _objectMap.clear();
  66. }
  67. /* (non-Javadoc)
  68. * @see com.l2jserver.util.L2ObjectSet#put(T)
  69. */
  70. @Override
  71. public void put(T obj)
  72. {
  73. _objectMap.put(obj.getObjectId(), obj);
  74. }
  75. /* (non-Javadoc)
  76. * @see com.l2jserver.util.L2ObjectSet#remove(T)
  77. */
  78. @Override
  79. public void remove(T obj)
  80. {
  81. _objectMap.remove(obj.getObjectId());
  82. }
  83. /* (non-Javadoc)
  84. * @see com.l2jserver.util.L2ObjectSet#contains(T)
  85. */
  86. @Override
  87. public boolean contains(T obj)
  88. {
  89. return _objectMap.containsKey(obj.getObjectId());
  90. }
  91. /* (non-Javadoc)
  92. * @see com.l2jserver.util.L2ObjectSet#iterator()
  93. */
  94. @Override
  95. public Iterator<T> iterator()
  96. {
  97. return _objectMap.values().iterator();
  98. }
  99. }