Package org.apache.commons.collections.map

Examples of org.apache.commons.collections.map.DefaultedMap


   * @return block data object
   */
  @SuppressWarnings("unchecked")
  public static BlockData fromInventory(Inventory inv)
  {
    Map<BlockData, Integer> count = new DefaultedMap(0);
    for (ItemStack item : inv) if (item != null)
    {
      BlockData bd = BlockData.fromItemStack(item);
      count.put(bd, item.getAmount() + count.get(bd));
    }

    Map.Entry<BlockData, Integer> best = null;
    for (Map.Entry<BlockData, Integer> entry : count.entrySet())
      if (best == null || entry.getValue() > best.getValue()) best = entry;

    return best == null ? null : best.getKey();
  }
View Full Code Here

TOP

Related Classes of org.apache.commons.collections.map.DefaultedMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.