2
0

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