WorldObjectMap.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * $Header: WorldObjectMap.java, 22/07/2005 14:15:11 luisantonioa Exp $
  3. *
  4. * $Author: luisantonioa $
  5. * $Date: 22/07/2005 14:15:11 $
  6. * $Revision: 1 $
  7. * $Log: WorldObjectMap.java,v $
  8. * Revision 1 22/07/2005 14:15:11 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 WorldObjectMap<T extends L2Object> extends L2ObjectMap<T>
  37. {
  38. Map<Integer, T> _objectMap = new FastMap<Integer, T>().shared();
  39. /* (non-Javadoc)
  40. * @see com.l2jserver.util.L2ObjectMap#size()
  41. */
  42. @Override
  43. public int size()
  44. {
  45. return _objectMap.size();
  46. }
  47. /* (non-Javadoc)
  48. * @see com.l2jserver.util.L2ObjectMap#isEmpty()
  49. */
  50. @Override
  51. public boolean isEmpty()
  52. {
  53. return _objectMap.isEmpty();
  54. }
  55. /* (non-Javadoc)
  56. * @see com.l2jserver.util.L2ObjectMap#clear()
  57. */
  58. @Override
  59. public void clear()
  60. {
  61. _objectMap.clear();
  62. }
  63. /* (non-Javadoc)
  64. * @see com.l2jserver.util.L2ObjectMap#put(T)
  65. */
  66. @Override
  67. public void put(T obj)
  68. {
  69. if (obj != null)
  70. _objectMap.put(obj.getObjectId(), obj);
  71. }
  72. /* (non-Javadoc)
  73. * @see com.l2jserver.util.L2ObjectMap#remove(T)
  74. */
  75. @Override
  76. public void remove(T obj)
  77. {
  78. if (obj != null)
  79. _objectMap.remove(obj.getObjectId());
  80. }
  81. /* (non-Javadoc)
  82. * @see com.l2jserver.util.L2ObjectMap#get(int)
  83. */
  84. @Override
  85. public T get(int id)
  86. {
  87. return _objectMap.get(id);
  88. }
  89. /* (non-Javadoc)
  90. * @see com.l2jserver.util.L2ObjectMap#contains(T)
  91. */
  92. @Override
  93. public boolean contains(T obj)
  94. {
  95. if (obj == null)
  96. return false;
  97. return _objectMap.get(obj.getObjectId()) != null;
  98. }
  99. /* (non-Javadoc)
  100. * @see com.l2jserver.util.L2ObjectMap#iterator()
  101. */
  102. @Override
  103. public Iterator<T> iterator()
  104. {
  105. return _objectMap.values().iterator();
  106. }
  107. }