2
0

WorldObjectSet.java 2.7 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.util;
  26. import java.util.Iterator;
  27. import java.util.Map;
  28. import com.l2jserver.gameserver.model.L2Object;
  29. import javolution.util.FastMap;
  30. /**
  31. * This class ...
  32. *
  33. * @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $
  34. */
  35. public class WorldObjectSet<T extends L2Object> extends L2ObjectSet<T>
  36. {
  37. private Map<Integer, T> _objectMap;
  38. public WorldObjectSet()
  39. {
  40. _objectMap = new FastMap<Integer, T>().shared();
  41. }
  42. /* (non-Javadoc)
  43. * @see com.l2jserver.util.L2ObjectSet#size()
  44. */
  45. @Override
  46. public int size()
  47. {
  48. return _objectMap.size();
  49. }
  50. /* (non-Javadoc)
  51. * @see com.l2jserver.util.L2ObjectSet#isEmpty()
  52. */
  53. @Override
  54. public boolean isEmpty()
  55. {
  56. return _objectMap.isEmpty();
  57. }
  58. /* (non-Javadoc)
  59. * @see com.l2jserver.util.L2ObjectSet#clear()
  60. */
  61. @Override
  62. public void clear()
  63. {
  64. _objectMap.clear();
  65. }
  66. /* (non-Javadoc)
  67. * @see com.l2jserver.util.L2ObjectSet#put(T)
  68. */
  69. @Override
  70. public void put(T obj)
  71. {
  72. _objectMap.put(obj.getObjectId(), obj);
  73. }
  74. /* (non-Javadoc)
  75. * @see com.l2jserver.util.L2ObjectSet#remove(T)
  76. */
  77. @Override
  78. public void remove(T obj)
  79. {
  80. _objectMap.remove(obj.getObjectId());
  81. }
  82. /* (non-Javadoc)
  83. * @see com.l2jserver.util.L2ObjectSet#contains(T)
  84. */
  85. @Override
  86. public boolean contains(T obj)
  87. {
  88. return _objectMap.containsKey(obj.getObjectId());
  89. }
  90. /* (non-Javadoc)
  91. * @see com.l2jserver.util.L2ObjectSet#iterator()
  92. */
  93. @Override
  94. public Iterator<T> iterator()
  95. {
  96. return _objectMap.values().iterator();
  97. }
  98. }