当前位置: 首页>>代码示例>>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;未经允许,请勿转载。