當前位置: 首頁>>代碼示例>>Java>>正文


Java Short2ObjectOpenHashMap類代碼示例

本文整理匯總了Java中it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap的典型用法代碼示例。如果您正苦於以下問題:Java Short2ObjectOpenHashMap類的具體用法?Java Short2ObjectOpenHashMap怎麽用?Java Short2ObjectOpenHashMap使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Short2ObjectOpenHashMap類屬於it.unimi.dsi.fastutil.shorts包,在下文中一共展示了Short2ObjectOpenHashMap類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isMatching

import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap; //導入依賴的package包/類
@Override
public CraftingRecipeCheckResult isMatching(final GridInventory inventory)
{
    final Player player = (inventory.getHolder() instanceof Player) ? (Player) inventory.getHolder() : null;
    final Short2ObjectMap<ItemStack> onCraft = new Short2ObjectOpenHashMap<>(2, .5F);

    final CraftingRecipePattern pattern = this.pattern;
    final int maxPatRow = pattern.getRows(), maxPatCol = pattern.getColumns();
    final int maxInvRow = inventory.getRows(), maxInvCol = inventory.getColumns();
    final CraftingGrid items = new CraftingGridImpl(maxInvRow, maxInvCol);
    final Collection<BiConsumer<Player, CraftingGrid>> reps = new ArrayList<>(maxInvCol * maxInvRow);
    final LinkedList<CraftingRecipeItem> ingredients = new LinkedList<>(this.getIngredients());
    final Collection<CraftingRepeatableRecipeItem> repeatableIngredients = new LinkedList<>(this.getRepeatableIngredients());
    final Map<CraftingRepeatableRecipeItem, List<ItemStack>> repeatableItems = new IdentityHashMap<>(this.repeatableIngredients.size());

    // TODO: ugh, no idea how to do this.
    return null;
}
 
開發者ID:Diorite,項目名稱:Diorite-old,代碼行數:19,代碼來源:SemiShapedCraftingRecipeImpl.java

示例2: LanternChunk

import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap; //導入依賴的package包/類
public LanternChunk(LanternWorld world, int x, int z) {
    this.world = world;
    this.key = key(x, z);
    this.x = x;
    this.z = z;

    final UUID worldUUID = this.world.getUniqueId();
    this.uniqueId = new UUID(worldUUID.getMostSignificantBits() ^ (x * 2 + 1),
            worldUUID.getLeastSignificantBits() ^ (z * 2 + 1));

    this.pos = new Vector3i(x, 0, z);
    this.chunkPos = this.pos.toVector2(true);
    this.min = LanternChunkLayout.INSTANCE.toWorld(this.pos).get();
    this.max = this.min.add(CHUNK_MASK);
    this.areaMin = this.min.toVector2(true);
    this.areaMax = this.max.toVector2(true);
    this.biomeMin = new Vector3i(this.min.getX(), 1, this.min.getZ());
    this.biomeMax = new Vector3i(this.max.getX(), 1, this.max.getZ());

    //noinspection unchecked
    final Short2ObjectMap<TrackerData>[] trackerDataSections = new Short2ObjectMap[CHUNK_SECTIONS];
    for (int i = 0; i < trackerDataSections.length; i++) {
        trackerDataSections[i] = new Short2ObjectOpenHashMap<>();
    }
    this.trackerData = new ConcurrentObjectArray<>(trackerDataSections);
}
 
開發者ID:LanternPowered,項目名稱:LanternServer,代碼行數:27,代碼來源:LanternChunk.java

示例3: CraftingRecipeCheckResultImpl

import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap; //導入依賴的package包/類
/**
 * Construct new CraftResult for given recipe and items.
 *
 * @param recipe         matched recipe.
 * @param result         result item stack.
 * @param itemsToConsume array of items that should be removed from inventory on craft.
 */
public CraftingRecipeCheckResultImpl(final CraftingRecipe recipe, final ItemStack result, final CraftingGrid itemsToConsume)
{
    this.recipe = recipe;
    this.result = result;
    this.itemsToConsume = itemsToConsume;
    this.onCraft = new Short2ObjectOpenHashMap<>(2, .5F);
}
 
開發者ID:Diorite,項目名稱:Diorite-old,代碼行數:15,代碼來源:CraftingRecipeCheckResultImpl.java

示例4: ChunkSection

import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap; //導入依賴的package包/類
ChunkSection(@Nullable short[] types) {
    if (types != null) {
        checkArgument(types.length == CHUNK_SECTION_VOLUME, "Type array length mismatch: Got "
                + types.length + ", but expected " + CHUNK_SECTION_VOLUME);
        this.types = new short[CHUNK_SECTION_VOLUME];
        System.arraycopy(types, 0, this.types, 0, CHUNK_SECTION_VOLUME);
        recountTypes();
    } else {
        this.types = new short[CHUNK_SECTION_VOLUME];
    }
    this.tileEntities = new Short2ObjectOpenHashMap<>();
    this.lightFromBlock = new NibbleArray(CHUNK_SECTION_VOLUME);
    this.lightFromSky = new NibbleArray(CHUNK_SECTION_VOLUME);
}
 
開發者ID:LanternPowered,項目名稱:LanternServer,代碼行數:15,代碼來源:LanternChunk.java

示例5: asSnapshot

import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap; //導入依賴的package包/類
private ChunkSectionSnapshot asSnapshot(boolean skylight) {
    final Short2ShortMap typeCounts = new Short2ShortOpenHashMap(this.typesCountMap);
    final int count = this.types.length - this.nonAirCount;
    if (count > 0) {
        typeCounts.put((short) 0, (short) count);
    }
    return new ChunkSectionSnapshot(this.types.clone(), typeCounts, new Short2ObjectOpenHashMap<>(this.tileEntities),
            this.lightFromBlock.getPackedArray(), skylight ? this.lightFromSky.getPackedArray() : null);
}
 
開發者ID:LanternPowered,項目名稱:LanternServer,代碼行數:10,代碼來源:LanternChunk.java

示例6: containsKey

import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap; //導入依賴的package包/類
/**
 * Test if a key is present in the hashmap.
 *
 * @param id Key to test
 * @return {@code true} when contained.
 */
public boolean containsKey(long id) {
  int prefix = (int) (id >>> shift);
  if(maxid > 0L && id >= maxid) {
    throw new RuntimeException("Too large node ids for this memory layout, increase SHIFT.");
  }
  Short2ObjectOpenHashMap<T> chunk = topmap.get(prefix);
  return (chunk != null) && chunk.containsKey((short) (id & mask));
}
 
開發者ID:kno10,項目名稱:reversegeocode,代碼行數:15,代碼來源:LongObjectHierarchicalMap.java

示例7: get

import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap; //導入依賴的package包/類
/**
 * Get the value of a key
 *
 * @param id key to retrieve
 * @return Value stored, or {@code null}
 */
public T get(long id) {
  int prefix = (int) (id >>> shift);
  if(maxid > 0L && id >= maxid) {
    throw new RuntimeException("Too large node ids for this memory layout.");
  }
  Short2ObjectOpenHashMap<T> chunk = topmap.get(prefix);
  if(chunk == null) {
    return null;
  }
  return chunk.get((short) (id & mask));
}
 
開發者ID:kno10,項目名稱:reversegeocode,代碼行數:18,代碼來源:LongObjectHierarchicalMap.java

示例8: getOrDefault

import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap; //導入依賴的package包/類
/**
 * Get the value of a key
 *
 * @param id key to retrieve
 * @param notfound Value to return when the key is not found.
 * @return Value stored, or {@code notfound}
 */
public T getOrDefault(long id, T notfound) {
  int prefix = (int) (id >>> shift);
  if(maxid > 0L && id >= maxid) {
    throw new RuntimeException("Too large node ids for this memory layout.");
  }
  Short2ObjectOpenHashMap<T> chunk = topmap.get(prefix);
  if(chunk == null) {
    return notfound;
  }
  return chunk.getOrDefault((short) (id & mask), notfound);
}
 
開發者ID:kno10,項目名稱:reversegeocode,代碼行數:19,代碼來源:LongObjectHierarchicalMap.java

示例9: put

import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap; //導入依賴的package包/類
/**
 * Store a value in the map.
 *
 * @param id Key
 * @param val Value
 */
public void put(long id, T val) {
  int prefix = (int) (id >>> shift);
  Short2ObjectOpenHashMap<T> chunk = topmap.get(prefix);
  if(chunk == null) {
    chunk = new Short2ObjectOpenHashMap<T>();
    topmap.put(prefix, chunk);
  }
  chunk.put((short) (id & mask), val);
}
 
開發者ID:kno10,項目名稱:reversegeocode,代碼行數:16,代碼來源:LongObjectHierarchicalMap.java

示例10: ValueIterator

import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap; //導入依賴的package包/類
/**
 * Constructor.
 *
 * @param outer Outer iterator
 */
public ValueIterator(ObjectIterator<Short2ObjectOpenHashMap<T>> outer) {
  this.outer = outer;
  if(outer.hasNext()) {
    inner = outer.next().values().iterator();
  }
  else {
    inner = Collections.emptyIterator();
  }
}
 
開發者ID:kno10,項目名稱:reversegeocode,代碼行數:15,代碼來源:LongObjectHierarchicalMap.java

示例11: computeSize

import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap; //導入依賴的package包/類
/**
 * Compute the size of the map.
 *
 * This is more expensive than your usual {@link size()} call, therefore we
 * chose a different name. It would be trivial to add a counter to provide
 * O(1) size.
 *
 * @return Size, by aggregating over all maps.
 */
public int computeSize() {
  int size = 0;
  for(Short2ObjectOpenHashMap<T> m : topmap.values()) {
    size += m.size();
  }
  return size;
}
 
開發者ID:kno10,項目名稱:reversegeocode,代碼行數:17,代碼來源:LongObjectHierarchicalMap.java


注:本文中的it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。