Java Code Examples for com.google.common.collect.TreeMultimap#values()

The following examples show how to use com.google.common.collect.TreeMultimap#values() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WalletUtil.java    From snowblossom with Apache License 2.0 6 votes vote down vote up
public static Collection<AddressSpecHash> getAddressesByAge(WalletDatabase db, NetworkParams params)
{
  TreeMultimap<Long, AddressSpecHash> age_map = TreeMultimap.create();
  for(AddressSpec spec : db.getAddressesList())
  {
    String addr = AddressUtil.getAddressString(spec, params);
    long tm = 0;
    if (db.getAddressCreateTimeMap().containsKey(addr))
    {
      tm = db.getAddressCreateTimeMap().get(addr);
    }
    age_map.put(tm, AddressUtil.getHashForSpec(spec));

  }

  return age_map.values();

}
 
Example 2
Source File: Intersection.java    From datawave with Apache License 2.0 5 votes vote down vote up
static TreeMultimap<String,IndexStream> pivot(TreeMultimap<String,IndexStream> children) {
    TreeMultimap<String,IndexStream> newChildren = TreeMultimap.create(Ordering.natural(), Ordering.arbitrary());
    final String max = children.keySet().last();
    newChildren.putAll(max, children.removeAll(max));
    for (IndexStream itr : children.values()) {
        // move this iterator forward until we get to a key past the max processed thus far
        String dayOrShard = null;
        while (itr.hasNext()) {
            
            dayOrShard = key(itr.peek());
            if (dayOrShard.compareTo(max) >= 0) {
                break;
            }
            if (isDay(dayOrShard) && max.startsWith(dayOrShard)) {
                // use the existing max instead of the day to add to the list
                dayOrShard = max;
                break;
            }
            itr.next();
        }
        // add the item into our map
        if (itr.hasNext()) {
            newChildren.put(dayOrShard, itr);
        } else {
            // nobody has anything past max, so no intersection
            return TreeMultimap.create(Ordering.natural(), Ordering.arbitrary());
        }
    }
    return newChildren;
}