示例#1
0
 /** Counts the object, increasing its total count by 1. */
 public int count(T obj) {
   int count = counts.get(obj);
   count++;
   counts.put(obj, count);
   sum++;
   return count;
 }
示例#2
0
 /**
  * Adds the counts from the provided {@code Counter} to the current counts, adding new elements as
  * needed.
  */
 public void add(Counter<? extends T> counter) {
   for (Map.Entry<? extends T, Integer> e : counter) {
     T t = e.getKey();
     Integer cur = counts.get(t);
     counts.put(t, (cur == null) ? e.getValue() : cur + e.getValue());
   }
 }
示例#3
0
 /**
  * Counts the object, increasing its total count by the specified positive amount.
  *
  * @param count a positive value for the number of times the object occurred
  * @throws IllegalArgumentException if {@code count} is not a positive value.
  */
 public int count(T obj, int count) {
   if (count < 1) throw new IllegalArgumentException("Count must be positive: " + count);
   int oldCount = counts.get(obj);
   int newCount = count + oldCount;
   counts.put(obj, newCount);
   sum += count;
   return newCount;
 }
示例#4
0
  private void load() {
    logger.trace("Loading creature postures datatable.");

    final DataTable dataTable = dataTableManager.getTable(dataTableName);

    for (int row = 0; row < dataTable.getNumRows(); ++row) {
      postures.put(dataTable.getStringValue("posture", row), dataTable.getIntValue("value", row));
    }

    dataTableManager.close(dataTableName);

    logger.debug(String.format("Loaded %d creature postures.", postures.size()));
  }
示例#5
0
 /**
  * Sets a property of the window
  *
  * @param id of the property
  * @param value value of property
  */
 public void setProperty(int id, int value) {
   properties.put(id, value);
   switch (Spout.getPlatform()) {
     case PROXY:
     case SERVER:
       callProtocolEvent(new WindowPropertyEvent(this, id, value));
       break;
     case CLIENT:
       // TODO: Window properties
       break;
     default:
       throw new IllegalStateException("Unknown platform: " + Spout.getPlatform());
   }
 }
示例#6
0
 /**
  * Adds an attribute.
  *
  * @param attribute The attribute to add
  */
 public void addAttribute(int index, VertexAttribute attribute) {
   attributes.put(index, attribute);
   nameToIndex.put(attribute.getName(), index);
 }