コード例 #1
0
ファイル: Solver.java プロジェクト: krasa/intellij-community
 void addEquation(IdEquation equation) {
   size++;
   IdResult rhs = equation.rhs;
   if (rhs instanceof IdFinal) {
     solved.put(equation.id, ((IdFinal) rhs).value);
     moving.push(equation.id);
   } else if (rhs instanceof IdPending) {
     IdPending pendResult = ((IdPending) rhs).copy();
     IdResult norm = normalize(pendResult.delta);
     if (norm instanceof IdFinal) {
       solved.put(equation.id, ((IdFinal) norm).value);
       moving.push(equation.id);
     } else {
       IdPending pendResult1 = ((IdPending) rhs).copy();
       for (IntIdComponent component : pendResult1.delta) {
         for (long trigger : component.ids) {
           TLongHashSet set = dependencies.get(trigger);
           if (set == null) {
             set = new TLongHashSet();
             dependencies.put(trigger, set);
           }
           set.add(equation.id);
         }
         pending.put(equation.id, pendResult1);
       }
     }
   }
 }
コード例 #2
0
 public final boolean execute(long key, Object value) {
   int index = _otherMap.index(key);
   if (index >= 0 && eq(value, _otherMap.get(key))) {
     return true;
   }
   return false;
 }
コード例 #3
0
ファイル: SimpleItemManager.java プロジェクト: dotblank/Spout
 public String getCustomItemTexturePlugin(Material item, short data) {
   long info = toLong(item.getId(), data);
   if (customTexturesPlugin.containsKey(info)) {
     return (String) customTexturesPlugin.get(info);
   }
   return null;
 }
コード例 #4
0
ファイル: SimpleItemManager.java プロジェクト: dotblank/Spout
 @Override
 public String getCustomItemName(Material item, short data) {
   long key = toLong(item.getId(), data);
   if (customNames.containsKey(key)) {
     return (String) customNames.get(key);
   }
   return null;
 }
コード例 #5
0
 /**
  * Compares this map with another map for equality of their stored entries.
  *
  * @param other an <code>Object</code> value
  * @return a <code>boolean</code> value
  */
 public boolean equals(Object other) {
   if (!(other instanceof TLongObjectHashMap)) {
     return false;
   }
   TLongObjectHashMap that = (TLongObjectHashMap) other;
   if (that.size() != this.size()) {
     return false;
   }
   return forEachEntry(new EqProcedure(that));
 }
コード例 #6
0
  public void testP2OMap() {
    // Long-long
    TLongObjectHashMap<Long> lomap = new TLongObjectHashMap<Long>();
    assertTrue(serializesCorrectly(lomap, "p2o-l-1"));
    lomap.put(0, Long.valueOf(1));
    assertTrue(serializesCorrectly(lomap, "p2o-l-2"));
    lomap.put(Long.MIN_VALUE, Long.valueOf(Long.MIN_VALUE));
    assertTrue(serializesCorrectly(lomap, "p2o-l-3"));
    lomap.put(Long.MAX_VALUE, Long.valueOf(Long.MAX_VALUE));
    assertTrue(serializesCorrectly(lomap, "p2o-l-4"));

    // Int-int
    TIntObjectHashMap<Integer> iomap = new TIntObjectHashMap<Integer>();
    assertTrue(serializesCorrectly(iomap, "p2o-i-1"));
    iomap.put(0, Integer.valueOf(1));
    assertTrue(serializesCorrectly(iomap, "p2o-i-2"));
    iomap.put(Integer.MIN_VALUE, Integer.valueOf(Integer.MIN_VALUE));
    assertTrue(serializesCorrectly(iomap, "p2o-i-3"));
    iomap.put(Integer.MAX_VALUE, Integer.valueOf(Integer.MAX_VALUE));
    assertTrue(serializesCorrectly(iomap, "p2o-i-4"));

    // Double-double
    TDoubleObjectHashMap<Double> domap = new TDoubleObjectHashMap<Double>();
    assertTrue(serializesCorrectly(domap, "p2o-d-1"));
    domap.put(0, Double.valueOf(1));
    assertTrue(serializesCorrectly(domap, "p2o-d-2"));
    domap.put(Double.MIN_VALUE, Double.valueOf(Double.MIN_VALUE));
    assertTrue(serializesCorrectly(domap, "p2o-d-3"));
    domap.put(Double.MAX_VALUE, Double.valueOf(Double.MAX_VALUE));
    assertTrue(serializesCorrectly(domap, "p2o-d-4"));
    domap.put(Double.POSITIVE_INFINITY, Double.valueOf(Double.POSITIVE_INFINITY));
    assertTrue(serializesCorrectly(domap, "p2o-d-5"));
    domap.put(Double.NEGATIVE_INFINITY, Double.valueOf(Double.NEGATIVE_INFINITY));
    assertTrue(serializesCorrectly(domap, "p2o-d-6"));
    // NOTE: trove doesn't deal well with NaN
    //        ddmap.put( Double.NaN, Double.NaN );
    //        assertTrue( serializesCorrectly( ddmap ) );

    // Float-float
    TFloatObjectHashMap<Float> fomap = new TFloatObjectHashMap<Float>();
    assertTrue(serializesCorrectly(fomap, "p2o-f-1"));
    fomap.put(0, Float.valueOf(1));
    assertTrue(serializesCorrectly(fomap, "p2o-f-2"));
    fomap.put(Float.MIN_VALUE, Float.valueOf(Float.MIN_VALUE));
    assertTrue(serializesCorrectly(fomap, "p2o-f-3"));
    fomap.put(Float.MAX_VALUE, Float.valueOf(Float.MAX_VALUE));
    assertTrue(serializesCorrectly(fomap, "p2o-f-4"));
    fomap.put(Float.POSITIVE_INFINITY, Float.valueOf(Float.POSITIVE_INFINITY));
    assertTrue(serializesCorrectly(fomap, "p2o-f-5"));
    fomap.put(Float.NEGATIVE_INFINITY, Float.valueOf(Float.NEGATIVE_INFINITY));
    assertTrue(serializesCorrectly(fomap, "p2o-f-6"));
    // NOTE: trove doesn't deal well with NaN
    //        ffmap.put( Float.NaN, Float.NaN );
    //        assertTrue( serializesCorrectly( ffmap ) );
  }
コード例 #7
0
ファイル: SimpleItemManager.java プロジェクト: dotblank/Spout
 @Override
 public void reset() {
   customNames.clear();
   customTextures.clear();
   for (Player player : Bukkit.getServer().getOnlinePlayers()) {
     if (player instanceof SpoutCraftPlayer) {
       if (((SpoutPlayer) player).isSpoutCraftEnabled()) {
         ((SpoutPlayer) player).sendPacket(new PacketItemName(0, (short) 0, "[resetall]"));
       }
     }
   }
 }
コード例 #8
0
ファイル: SimpleItemManager.java プロジェクト: dotblank/Spout
  @Override
  public void setCustomBlockDesign(Integer blockId, Integer metaData, BlockDesign design) {
    Player[] players = Spout.getInstance().getServer().getOnlinePlayers();

    long info = toLong(blockId, metaData);

    if (design != null) {
      customBlockDesigns.put(info, design);
    } else {
      customBlockDesigns.remove(info);
    }

    updateCustomBlockDesigns(players, info, design);
  }
コード例 #9
0
ファイル: SimpleItemManager.java プロジェクト: dotblank/Spout
 @Override
 public void resetName(Material item, short data) {
   long key = toLong(item.getId(), data);
   if (customNames.containsKey(key)) {
     customNames.remove(key);
     for (Player player : Bukkit.getServer().getOnlinePlayers()) {
       if (player instanceof SpoutCraftPlayer) {
         if (((SpoutPlayer) player).isSpoutCraftEnabled()) {
           ((SpoutPlayer) player)
               .sendPacket(new PacketItemName(msw(key), (short) lsw(key), "[reset]"));
         }
       }
     }
   }
 }
コード例 #10
0
ファイル: SimpleItemManager.java プロジェクト: dotblank/Spout
 @Override
 public void resetTexture(Material item, short data) {
   long info = toLong(item.getId(), data);
   if (customTextures.containsKey(info)) {
     customTextures.remove(info);
     String pluginName = (String) customTexturesPlugin.remove(info);
     for (Player player : Bukkit.getServer().getOnlinePlayers()) {
       if (player instanceof SpoutCraftPlayer) {
         if (((SpoutPlayer) player).isSpoutCraftEnabled()) {
           ((SpoutPlayer) player)
               .sendPacket(
                   new PacketItemTexture(msw(info), (short) lsw(info), pluginName, "[reset]"));
         }
       }
     }
   }
 }
コード例 #11
0
 public boolean containsKey(SNodeId key) {
   if (key instanceof Regular) {
     return myRegularMap.containsKey(((Regular) key).getId());
   } else if (key instanceof Foreign) {
     return myForeignMap.containsKey(((Foreign) key).getId());
   } else {
     return myOtherMap.containsKey(key);
   }
 }
コード例 #12
0
 public SNode put(SNodeId key, SNode value) {
   if (key instanceof Regular) {
     return myRegularMap.put(((Regular) key).getId(), value);
   } else if (key instanceof Foreign) {
     return myForeignMap.put(((Foreign) key).getId(), value);
   } else {
     return myOtherMap.put(key, value);
   }
 }
コード例 #13
0
ファイル: RegularNodeIdMap.java プロジェクト: brigand/MPS
 @Override
 public SNode put(SNodeId key, SNode value) {
   if (!(key instanceof Regular)) {
     LOG.error(
         "Trying to add node with id class " + key.getClass().getName() + " to a regular model");
     return null;
   }
   return myRegularMap.put(((Regular) key).getId(), value);
 }
コード例 #14
0
ファイル: SimpleItemManager.java プロジェクト: dotblank/Spout
 public void onPlayerJoin(SpoutPlayer player) {
   if (((SpoutPlayer) player).isSpoutCraftEnabled()) {
     for (TLongObjectIterator it = customNames.iterator(); it.hasNext(); ) {
       it.advance();
       ((SpoutPlayer) player)
           .sendPacket(
               new PacketItemName(msw(it.key()), (short) lsw(it.key()), (String) it.value()));
     }
     for (TLongObjectIterator it = customTextures.iterator(); it.hasNext(); ) {
       it.advance();
       String pluginName = (String) customTexturesPlugin.get(it.key());
       ((SpoutPlayer) player)
           .sendPacket(
               new PacketItemTexture(
                   msw(it.key()), (short) lsw(it.key()), pluginName, (String) it.value()));
     }
   }
 }
コード例 #15
0
 public SNode remove(SNodeId key) {
   if (key instanceof Regular) {
     return myRegularMap.remove(((Regular) key).getId());
   } else if (key instanceof Foreign) {
     return myForeignMap.remove(((Foreign) key).getId());
   } else {
     return myOtherMap.remove(key);
   }
 }
コード例 #16
0
ファイル: SimpleItemManager.java プロジェクト: dotblank/Spout
 @Override
 public void setItemName(Material item, short data, String name) {
   customNames.put(toLong(item.getId(), data), name);
   for (Player player : Bukkit.getServer().getOnlinePlayers()) {
     if (player instanceof SpoutCraftPlayer) {
       if (((SpoutPlayer) player).isSpoutCraftEnabled()) {
         ((SpoutPlayer) player).sendPacket(new PacketItemName(item.getId(), data, name));
       }
     }
   }
 }
コード例 #17
0
ファイル: RegularNodeIdMap.java プロジェクト: brigand/MPS
 @Override
 public SNode remove(SNodeId key) {
   if (!(key instanceof Regular)) {
     LOG.error(
         "Trying to remove node with id class "
             + key.getClass().getName()
             + " from a regular model");
     return null;
   }
   return myRegularMap.remove(((Regular) key).getId());
 }
コード例 #18
0
ファイル: SimpleItemManager.java プロジェクト: dotblank/Spout
 @Override
 public void setItemTexture(Material item, short data, Plugin plugin, String texture) {
   String pluginName;
   if (plugin == null) {
     pluginName = null;
   } else {
     pluginName = plugin.getDescription().getName();
   }
   long newKey = toLong(item.getId(), data);
   customTextures.put(newKey, texture);
   if (pluginName == null) {
     customTexturesPlugin.remove(newKey);
   } else {
     customTexturesPlugin.put(newKey, pluginName);
   }
   for (Player player : Bukkit.getServer().getOnlinePlayers()) {
     if (player instanceof SpoutCraftPlayer) {
       if (((SpoutPlayer) player).isSpoutCraftEnabled()) {
         ((SpoutPlayer) player)
             .sendPacket(new PacketItemTexture(item.getId(), data, pluginName, texture));
       }
     }
   }
 }
コード例 #19
0
ファイル: Solver.java プロジェクト: krasa/intellij-community
  TLongObjectHashMap<Value> solve() {
    while (!moving.empty()) {
      long id = moving.pop();
      Value value = solved.get(id);

      boolean stable = id > 0;
      long[] pIds = stable ? new long[] {id, -id} : new long[] {-id, id};
      Value[] pVals = stable ? new Value[] {value, value} : new Value[] {value, lattice.top};

      for (int i = 0; i < pIds.length; i++) {
        long pId = pIds[i];
        Value pVal = pVals[i];
        TLongHashSet dIds = dependencies.get(pId);
        if (dIds == null) {
          continue;
        }
        TLongIterator dIdsIterator = dIds.iterator();
        while (dIdsIterator.hasNext()) {
          long dId = dIdsIterator.next();
          IdPending pend = pending.remove(dId);
          if (pend != null) {
            IdResult pend1 = substitute(pend, pId, pVal);
            if (pend1 instanceof IdFinal) {
              IdFinal fi = (IdFinal) pend1;
              solved.put(dId, fi.value);
              moving.push(dId);
            } else {
              pending.put(dId, (IdPending) pend1);
            }
          }
        }
      }
    }
    pending.clear();
    return solved;
  }
コード例 #20
0
ファイル: RegularNodeIdMap.java プロジェクト: brigand/MPS
 @Override
 public Iterable<SNode> values() {
   return ((Iterable) Arrays.asList(myRegularMap.getValues()));
 }
コード例 #21
0
ファイル: RegularNodeIdMap.java プロジェクト: brigand/MPS
 @Override
 public boolean containsKey(SNodeId key) {
   if (!(key instanceof Regular)) return false;
   return myRegularMap.containsKey(((Regular) key).getId());
 }
コード例 #22
0
ファイル: SimpleItemManager.java プロジェクト: dotblank/Spout
 public void updateAllCustomBlockDesigns(Player[] players) {
   for (TLongObjectIterator it = customBlockDesigns.iterator(); it.hasNext(); ) {
     it.advance();
     updateCustomBlockDesigns(players, it.key(), (BlockDesign) it.value());
   }
 }
コード例 #23
0
ファイル: RegularNodeIdMap.java プロジェクト: brigand/MPS
 @Override
 public SNode get(SNodeId key) {
   if (!(key instanceof Regular)) return null;
   return myRegularMap.get(((Regular) key).getId());
 }
コード例 #24
0
ファイル: RegularNodeIdMap.java プロジェクト: brigand/MPS
 @Override
 public int size() {
   return myRegularMap.size();
 }
コード例 #25
0
 public int size() {
   return myRegularMap.size() + myForeignMap.size() + myOtherMap.size();
 }
コード例 #26
0
 @Override
 public MethodInfo getMethodInfo(long hash) {
   MethodInfo info = (MethodInfo) methodInfos.get(hash);
   return info;
 }
コード例 #27
0
 public void addMethodInfo(MethodInfo info) {
   methodInfos.put(info.getHash(), info);
 }
コード例 #28
0
 public Iterable<SNode> values() {
   Iterator<SNode> regular = ((Iterable) Arrays.asList(myRegularMap.getValues())).iterator();
   Iterator<SNode> foreign = myForeignMap.values().iterator();
   Iterator<SNode> other = myOtherMap.values().iterator();
   return new MergeIterator<SNode>(regular, new MergeIterator<SNode>(foreign, other));
 }
コード例 #29
0
 public MethodInfo[] getMethodInfos() {
   Object[] vals = methodInfos.getValues();
   MethodInfo[] infos = new MethodInfo[vals.length];
   System.arraycopy(vals, 0, infos, 0, vals.length);
   return infos;
 }
コード例 #30
0
 /** @return a deep clone of this collection */
 public TLongObjectHashMap<V> clone() {
   TLongObjectHashMap<V> m = (TLongObjectHashMap<V>) super.clone();
   m._values = (V[]) this._values.clone();
   return m;
 }