public int completed(R request) {
   assert request.equals(requests.peek());
   requests.poll();
   int remaining = requests.size();
   if (remaining != 0) coordinator.send(requests.peek());
   return remaining;
 }
Example #2
0
 public static void main(String[] args) {
   HashSet hs = new HashSet();
   hs.add(new R(5));
   hs.add(new R(-3));
   hs.add(new R(9));
   hs.add(new R(-2));
   // 打印HashSet集合,集合元素没有重复
   System.out.println(hs);
   // 取出第一个元素
   Iterator it = hs.iterator();
   R first = (R) it.next();
   // 为第一个元素的count实例变量赋值
   first.count = -3; // ①
   // 再次输出HashSet集合,集合元素有重复元素
   System.out.println(hs);
   // 删除count为-3的R对象
   hs.remove(new R(-3)); // ②
   // 可以看到被删除了一个R元素
   System.out.println(hs);
   System.out.println("hs是否包含count为-3的R对象?" + hs.contains(new R(-3))); // 输出false
   System.out.println("hs是否包含count为-2的R对象?" + hs.contains(new R(-2))); // 输出false
 }
Example #3
0
 /**
  * To find in the union, find in the components, concatenate the results, and omit duplicates.
  * That last is a performance penalty, but I see no way to remove it unless we know the graphs do
  * not overlap.
  */
 @Override
 public ExtendedIterator<Triple> graphBaseFind(final TripleMatch t) {
   Set<Triple> seen = CollectionFactory.createHashedSet();
   return recording(L.find(t), seen).andThen(rejecting(R.find(t), seen));
   // return L.find( t ) .andThen( rejecting( R.find( t ), L ) );
 }
Example #4
0
 @Override
 public boolean graphBaseContains(Triple t) {
   return L.contains(t) || R.contains(t);
 }
Example #5
0
 /** To remove a triple, remove it from <i>both</i> operands. */
 @Override
 public void performDelete(Triple t) {
   L.delete(t);
   R.delete(t);
 }