/**
   * Creates a new <code>TIntIntHashMap</code> instance containing all of the entries in the map
   * passed in.
   *
   * @param keys a <tt>int</tt> array containing the keys for the matching values.
   * @param values a <tt>int</tt> array containing the values.
   */
  public TIntIntHashMap(int[] keys, int[] values) {
    super(Math.max(keys.length, values.length));

    int size = Math.min(keys.length, values.length);
    for (int i = 0; i < size; i++) {
      this.put(keys[i], values[i]);
    }
  }
  /**
   * Creates a new <code>TLongFloatHashMap</code> instance containing all of the entries in the map
   * passed in.
   *
   * @param keys a <tt>long</tt> array containing the keys for the matching values.
   * @param values a <tt>float</tt> array containing the values.
   */
  public TLongFloatHashMap(long[] keys, float[] values) {
    super(Math.max(keys.length, values.length));

    int size = Math.min(keys.length, values.length);
    for (int i = 0; i < size; i++) {
      this.put(keys[i], values[i]);
    }
  }
  /**
   * Creates a new <code>TByteShortHashMap</code> instance containing all of the entries in the map
   * passed in.
   *
   * @param keys a <tt>byte</tt> array containing the keys for the matching values.
   * @param values a <tt>short</tt> array containing the values.
   */
  public TByteShortHashMap(byte[] keys, short[] values) {
    super(Math.max(keys.length, values.length));

    int size = Math.min(keys.length, values.length);
    for (int i = 0; i < size; i++) {
      this.put(keys[i], values[i]);
    }
  }
  /**
   * Creates a new <code>TDoubleCharHashMap</code> instance containing all of the entries in the map
   * passed in.
   *
   * @param keys a <tt>double</tt> array containing the keys for the matching values.
   * @param values a <tt>char</tt> array containing the values.
   */
  public TDoubleCharHashMap(double[] keys, char[] values) {
    super(Math.max(keys.length, values.length));

    int size = Math.min(keys.length, values.length);
    for (int i = 0; i < size; i++) {
      this.put(keys[i], values[i]);
    }
  }
Example #5
0
  /**
   * Creates a new <code>TFloatByteHashMap</code> instance containing all of the entries in the map
   * passed in.
   *
   * @param keys a <tt>float</tt> array containing the keys for the matching values.
   * @param values a <tt>byte</tt> array containing the values.
   */
  public TFloatByteHashMap(float[] keys, byte[] values) {
    super(Math.max(keys.length, values.length));

    int size = Math.min(keys.length, values.length);
    for (int i = 0; i < size; i++) {
      this.put(keys[i], values[i]);
    }
  }
 /**
  * Grow the internal array as needed to accommodate the specified number of elements. The size of
  * the array bytes on each resize unless capacity requires more than twice the current capacity.
  */
 public void ensureCapacity(int capacity) {
   int oldCapacity = capacity();
   if (capacity > oldCapacity) {
     int newCap = Math.max(oldCapacity << 1, capacity);
     _data.resize(newCap);
   }
 }
 @NotNull
 private static String toVfString(@NotNull Collection<VirtualFile> list) {
   List<VirtualFile> sub = new ArrayList<VirtualFile>(list).subList(0, Math.min(list.size(), 100));
   return list.size()
       + " files: "
       + StringUtil.join(sub, file -> file.getName(), ", ")
       + (list.size() == sub.size() ? "" : "...");
 }
Example #8
0
 public void update(final DisplayedScreenWorld world, final int deltaTime) {
   this.m_position += deltaTime;
   final ArrayList<DisplayedScreenMap> maps = world.getMaps();
   for (int i = maps.size() - 1; i >= 0; --i) {
     final DisplayedScreenMap map = maps.get(i);
     if (map != null) {
       final DisplayedScreenElement[] elts = map.getElements();
       if (elts != null) {
         for (final DisplayedScreenElement elt : elts) {
           if (elt.isVisible()) {
             final int id = elt.getElement().getCommonProperties().getId();
             if (Sea.WATER_ELEMENTS.contains(id)) {
               final float x = elt.getWorldCellX();
               final float y = elt.getWorldCellY();
               final float d =
                   (float) Math.sqrt(x * x + y * y) + this.m_speed * this.m_position / 1000.0f;
               float amplitude = this.m_amplitude * MathHelper.sinf(6.2831855f * d / this.m_width);
               if (amplitude < 0.0f) {
                 amplitude *= 0.2f;
               }
               final BatchTransformer batchTransformer = elt.getEntitySprite().getTransformer();
               final float tx = batchTransformer.getMatrix().getBuffer()[12];
               final float ty = batchTransformer.getMatrix().getBuffer()[13];
               batchTransformer
                   .getMatrix()
                   .set(
                       new float[] {
                         1.0f + amplitude,
                         0.0f,
                         0.0f,
                         0.0f,
                         0.0f,
                         1.0f + amplitude,
                         0.0f,
                         0.0f,
                         0.0f,
                         0.0f,
                         0.0f,
                         0.0f,
                         tx,
                         ty,
                         0.0f,
                         1.0f
                       });
             }
           }
         }
       }
     }
   }
 }
 /**
  * Creates a new <code>TIntIntHashMap</code> instance containing all of the entries in the map
  * passed in.
  *
  * @param map a <tt>TIntIntMap</tt> that will be duplicated.
  */
 public TIntIntHashMap(TIntIntMap map) {
   super(map.size());
   if (map instanceof TIntIntHashMap) {
     TIntIntHashMap hashmap = (TIntIntHashMap) map;
     this._loadFactor = hashmap._loadFactor;
     this.no_entry_key = hashmap.no_entry_key;
     this.no_entry_value = hashmap.no_entry_value;
     //noinspection RedundantCast
     if (this.no_entry_key != (int) 0) {
       Arrays.fill(_set, this.no_entry_key);
     }
     //noinspection RedundantCast
     if (this.no_entry_value != (int) 0) {
       Arrays.fill(_values, this.no_entry_value);
     }
     setUp((int) Math.ceil(DEFAULT_CAPACITY / _loadFactor));
   }
   putAll(map);
 }
 private void queueUnresolvedFilesSinceLastRestart() {
   PersistentFS fs = PersistentFS.getInstance();
   int maxId = FSRecords.getMaxId();
   TIntArrayList list = new TIntArrayList();
   for (int id = fileIsResolved.nextClearBit(1);
       id >= 0 && id < maxId;
       id = fileIsResolved.nextClearBit(id + 1)) {
     int nextSetBit = fileIsResolved.nextSetBit(id);
     int endOfRun = Math.min(maxId, nextSetBit == -1 ? maxId : nextSetBit);
     do {
       VirtualFile virtualFile = fs.findFileById(id);
       if (queueIfNeeded(virtualFile, myProject)) {
         list.add(id);
       } else {
         fileIsResolved.set(id);
       }
     } while (++id < endOfRun);
   }
   log("Initially added to resolve " + toVfString(list.toNativeArray()));
 }
 private static int getAbsId(@NotNull VirtualFile file) {
   return Math.abs(((VirtualFileWithId) file).getId());
 }