public void lookup(B key) throws IOException {

    waitingNext = false;
    if (matchingMode == MATCHING_MODE.ALL_MATCHES) {
      lookupIndex = 0;
      for (int lookupIndexLocal = 0; lookupIndexLocal < lookupListSize; lookupIndexLocal++) {
        ILookupManagerUnit<B> tempLookup = lookupList[lookupIndexLocal];
        tempLookup.lookup(key);
      }
    } else {
      try {
        if (lookupKey.compareTo(key) == 0 && previousResultRetrieved) {
          nextIsPreviousResult = true;
        } else {
          previousResultRetrieved = false;
          previousResult = null;
        }
      } catch (NullPointerException e) {
        previousResultRetrieved = false;
        previousResult = null;
      }
      noMoreNext = false;
    }
    key.copyDataTo(lookupKey);
    lookupKeyIsInitialized = true;
  }
Esempio n. 2
0
  @Ignore("alias property not supported yet")
  public void testBwoValues() throws Exception {
    CompassSession session = openSession();

    A a = new A();
    a.id = 1;
    a.value = "value";
    B b = new B();
    b.value = "bvalue";
    b.value2 = "bvalue2";
    a.b = b;
    session.save(a);

    Resource resource = session.loadResource(A.class, 1);
    assertNotNull(resource);
    assertEquals(6, resource.getProperties().length);
    assertEquals("A", resource.getAlias());
    assertEquals(3, resource.getProperties("value").length);

    a = (A) session.load(A.class, 1);
    assertEquals(1, a.id.longValue());
    assertNull(a.value);
    assertNull(a.b);

    session.close();
  }
  // negamax with alpha beta pruning
  private int negamax(B board, int depth, int alpha, int beta) {

    if (depth == 0) {
      return evaluator.eval(board);
    }

    // get all moves
    List<M> moves = board.generateMoves();

    // no legal moves, checkmate or stalemate
    if (moves.isEmpty()) {
      if (board.inCheck()) return -evaluator.mate() - depth;
      else return -evaluator.stalemate();
    }

    // iterate through all moves
    for (M move : moves) {
      board.applyMove(move);

      // call negamax on next move
      int nega = -negamax(board, depth - 1, -beta, -alpha);
      // update best move
      if (depth == maxDepth && alpha < nega) bestMove = move;
      // update alpha
      alpha = Math.max(alpha, nega);

      board.undoMove();

      // alpha beta pruning
      if (alpha >= beta) return alpha;
    }

    return alpha;
  }
  public static void main(String[] args) {
    B b = new B();
    b.aMethod();

    A a = (A) b;
    a.aMethod();
  }
Esempio n. 5
0
 public XMPPBean exchange(B bean, ResultBeanType resultBeanPrototype, int retries) {
   synchronized (this) {
     this.maxRetries = retries;
     this.beanOut = bean;
     this.resultBeanPrototype = resultBeanPrototype;
     try {
       // add IQ provider if necessary
       if (ProviderManager.getInstance()
               .getIQProvider(
                   resultBeanPrototype.getChildElement(), resultBeanPrototype.getNamespace())
           == null) {
         (new BeanProviderAdapter(resultBeanPrototype.getClass().newInstance()))
             .addToProviderManager();
       }
       if (ProviderManager.getInstance().getIQProvider(bean.getChildElement(), bean.getNamespace())
           == null) {
         (new BeanProviderAdapter(bean.getClass().newInstance())).addToProviderManager();
       }
     } catch (InstantiationException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     } catch (IllegalAccessException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
     // catch response bean and error bean
     this.beanCollector =
         connection.createPacketCollector(
             new OrFilter(
                 new BeanFilterAdapter(resultBeanPrototype), new BeanFilterAdapter(bean)));
     return sendAndWaitForResult(bean);
   }
 }
Esempio n. 6
0
  @Override
  public boolean instantiateTo(int value, ICause cause, boolean informCause)
      throws ContradictionException {
    if (informCause) {
      cause = Cause.Null;
    }
    if (this.instantiated()) {
      if (value != this.getValue()) {
        this.contradiction(cause, MSG_INST);
      }
      return false;
    } else if (contains(value)) {
      // todo: delta
      this.LB.set(value);
      this.UB.set(value);
      this.SIZE.set(1);

      A.updateUpperBound(value, this, false);
      B.updateUpperBound(value, this, false);
      if (!A.contains(value)) {
        B.instantiateTo(value, this, false);
      }
      if (!B.contains(value)) {
        A.instantiateTo(value, this, false);
      }

      this.notifyPropagators(EventType.INSTANTIATE, cause);
      return true;
    } else {
      this.contradiction(cause, MSG_UNKNOWN);
      return false;
    }
  }
  @Test
  public void autos5() {
    TestPage p = new TestPage();
    p.setPageMarkup(
        "<wicket:enclosure child='a'><div wicket:id='a'></div><div wicket:id='b'></div></wicket:enclosure>");
    A a = new A();
    B b = new B();
    p.queue(a);
    p.add(b);
    tester.startPage(p);

    assertTrue(a.getParent() instanceof Enclosure);
    assertTrue(b.getParent() instanceof TestPage);

    // A is visible, enclosure renders

    assertEquals(
        "<wicket:enclosure child=\"a\"><div wicket:id=\"a\"></div><div wicket:id=\"b\"></div></wicket:enclosure>",
        tester.getLastResponseAsString());

    // A is not visible, enclosure does not render

    a.setVisible(false);
    tester.startPage(p);
    assertEquals("", tester.getLastResponseAsString());
  }
  /** Test InlineEnclosure */
  @Test
  public void autos6() {
    TestPage p = new TestPage();
    p.setPageMarkup(
        "<div wicket:enclosure='a'><div wicket:id='a'></div><div wicket:id='b'></div></div>");
    A a = new A();
    B b = new B();
    p.queue(a, b);
    tester.startPage(p);

    assertTrue(a.getParent() instanceof Enclosure);
    assertTrue(b.getParent() instanceof Enclosure);

    // A is visible, enclosure renders

    assertEquals(
        "<div wicket:enclosure=\"a\" id=\"wicket__InlineEnclosure_01\"><div wicket:id=\"a\"></div><div wicket:id=\"b\"></div></div>",
        tester.getLastResponseAsString());

    // A is not visible, inline enclosure render only itself (the placeholder tag)

    a.setVisible(false);
    tester.startPage(p);
    assertEquals(
        "<div id=\"wicket__InlineEnclosure_01\" style=\"display:none\"></div>",
        tester.getLastResponseAsString());
  }
  /** Merge the congruence classes containing vertices v1 and v2.; */
  public void mergeClasses(OPT_ValueGraphVertex v1, OPT_ValueGraphVertex v2) {
    if (DEBUG) {
      System.out.println("@@@@ mergeClasses called with v1 = " + v1 + " ; v2 = " + v2);
    }

    int val1 = v1.getValueNumber();
    int val2 = v2.getValueNumber();
    if (val1 == val2) return;

    OPT_GVCongruenceClass class1 = (OPT_GVCongruenceClass) B.get(val1);

    while (true) {
      OPT_GVCongruenceClass class2 = (OPT_GVCongruenceClass) B.get(val2);
      Iterator i = class2.iterator();
      if (!i.hasNext()) break;
      OPT_ValueGraphVertex v = (OPT_ValueGraphVertex) i.next();
      if (DEBUG)
        System.out.println("@@@@ moving vertex " + v + " from class " + val2 + " to class " + val1);
      class1.addVertex(v);
      class2.removeVertex(v);
      v.setValueNumber(val1);
    }

    // Null out entry for val2
    B.set(val2, null);
  }
Esempio n. 10
0
  @Ignore("alias property not supported yet")
  public void testBCollection() throws Exception {
    CompassSession session = openSession();

    A a = new A();
    a.id = 1;
    a.value = "value";
    a.bs = new ArrayList<B>();
    B b = new B();
    b.value = "bvalue11";
    b.value2 = "bvalue12";
    a.bs.add(b);
    b = new B();
    b.value = "bvalue21";
    b.value = "bvalue22";
    a.bs.add(b);
    session.save(a);

    Resource resource = session.loadResource(A.class, 1);
    assertNotNull(resource);
    assertEquals(7, resource.getProperties().length);
    assertEquals("A", resource.getAlias());
    assertEquals(4, resource.getProperties("value").length);

    session.close();
  }
 CraftAIPart(AIController<E> controller, B behavior) {
   this.controller = controller;
   this.behavior = behavior;
   this.priority = behavior.getPriority(controller.lastBehaviorPriority);
   controller.lastBehaviorPriority = Math.max(controller.lastBehaviorPriority, this.priority);
   this.goal = behavior.createPathfinderGoal(controller.mob);
   this.type = behavior.getType();
 }
Esempio n. 12
0
 public MaxView(IntVar a, IntVar b, Solver solver) {
   super(a, b, solver);
   int lb = Math.max(A.getLB(), B.getLB());
   int ub = Math.max(A.getUB(), B.getUB());
   LB.set(lb);
   UB.set(ub);
   SIZE.set(ub - lb + 1);
 }
Esempio n. 13
0
 public static void main(String[] x) {
   B b = new B();
   A a = b;
   b.x = 11;
   b.y = 22;
   System.out.println(a.f());
   System.out.println(a.g());
 }
Esempio n. 14
0
  public static void main(String[] args) {

    A obj = new B();
    obj.show();
    B ob = new B();
    ob.show1();
    ob.show();
    System.out.println(ob.i);
  }
Esempio n. 15
0
  public static void main(String[] args) {
    B b;
    int rv;
    b = new B();
    System.out.println(5555);
    rv = b.foo();

    System.out.println(rv);
  }
Esempio n. 16
0
File: D.java Progetto: vjetteam/vjet
  public void method_usages() {
    String s = getB().getName();
    this.s_d_c.getName();
    A.getC().getName();
    B.getC().getName();
    new D().m_d_c.getName();

    B.getSomething();
    A.getSomething();
  }
Esempio n. 17
0
  public static void main(String[] args) {
    System.out.println("Hello World!");
    A a = new A();
    a.fun();
    B b = new B();
    b.fun();
    // C c=new C(); //Error:conflicts in Class C objects
    //  c.fun();

  }
Esempio n. 18
0
 @Override
 public void backPropagate(int mask) throws ContradictionException {
   // one of the variable as changed externally, this involves a complete update of this
   if (!EventType.isRemove(mask)) {
     int elb = A.getLB() + B.getLB();
     int eub = A.getUB() + B.getUB();
     int ilb = LB.get();
     int iub = UB.get();
     int old_size = iub - ilb; // is == 0, then the view is already instantiated
     boolean up = false, down = false;
     EventType e = EventType.VOID;
     if (elb > ilb) {
       if (elb > iub) {
         this.contradiction(this, MSG_LOW);
       }
       VALUES.clear(ilb - OFFSET, elb - OFFSET);
       ilb = VALUES.nextSetBit(ilb - OFFSET) + OFFSET;
       LB.set(ilb);
       e = EventType.INCLOW;
       down = true;
     }
     if (eub < iub) {
       if (eub < ilb) {
         this.contradiction(this, MSG_LOW);
       }
       VALUES.clear(eub - OFFSET + 1, iub - OFFSET + 1);
       iub = VALUES.prevSetBit(iub - OFFSET + 1) + OFFSET;
       UB.set(iub);
       if (e != EventType.VOID) {
         e = EventType.BOUND;
       } else {
         e = EventType.DECUPP;
       }
       up = true;
     }
     int size = VALUES.cardinality();
     SIZE.set(size);
     if (ilb > iub) {
       this.contradiction(this, MSG_EMPTY);
     }
     if (down || size == 1) {
       filterOnGeq(this, ilb);
     }
     if (up || size == 1) { // size == 1 means instantiation, then force filtering algo
       filterOnLeq(this, iub);
     }
     if (ilb == iub) { // size == 1 means instantiation, then force filtering algo
       if (old_size > 0) {
         notifyPropagators(EventType.INSTANTIATE, this);
       }
     } else {
       notifyPropagators(e, this);
     }
   }
 }
Esempio n. 19
0
  @Test
  // map null wrapper object to string. expectation: string should be null
  public void testB2AwithNullWrapper() {
    B b = new B();
    b.code = null;

    A a = mapper.map(b, A.class);

    Assert.assertNotNull(a);
    Assert.assertNull(a.code);
  }
Esempio n. 20
0
 public static void main(String args[]) {
   //  System.out.println("=============");
   //  A objA = new A();
   System.out.println("=============");
   B objB1 = new B();
   objB1.display();
   System.out.println("=============");
   B objB2 = new B(50, 60);
   objB2.display();
   System.out.println("=============");
 }
Esempio n. 21
0
 public static <F extends Serializable, B extends BusinessEntity<F>>
     Map<F, B> businessEntitiesById(Collection<B> entities) {
   if (entities != null) {
     Map<F, B> map = new HashMap<>();
     for (B b : entities) {
       map.put(b.getId(), b);
     }
     return map;
   } else {
     return Collections.emptyMap();
   }
 }
Esempio n. 22
0
  @Test
  // map wrapper object to string. expectation: string should contain content of wrapper object
  public void testB2AwithValue() {
    B b = new B();
    b.code = new WrapperObject();
    b.code.setId("x");

    A a = mapper.map(b, A.class);

    Assert.assertNotNull(a);
    Assert.assertEquals(b.code.getId(), a.code);
  }
Esempio n. 23
0
  @Test
  // map wrapper object with null content to string. expectation: string should be null
  public void testB2AwithNullValue() {
    B b = new B();
    b.code = new WrapperObject();
    b.code.setId(null);

    A a = mapper.map(b, A.class);

    Assert.assertNotNull(a);
    Assert.assertNull(a.code);
  }
Esempio n. 24
0
  @Test
  // map null string to wrapper object. expectation: wrapper object should be null
  public void testA2BwithNullValue() {
    B b = new B();
    b.code = new WrapperObject();
    b.code.setId(null);

    A a = mapper.map(b, A.class);

    Assert.assertNotNull(a);
    Assert.assertNull(a.code);
  }
Esempio n. 25
0
  public static void main(String[] args) {
    int i = (1 << 16) - 1;
    System.err.println(i);

    A a = new A();
    A a1 = a.clone();

    B b = new B();
    B b1 = b.clone();

    System.err.println(a1);
    System.err.println(b1);
  }
Esempio n. 26
0
 @Override
 public boolean removeValue(int value, ICause cause, boolean informCause)
     throws ContradictionException {
   ICause antipromo = cause;
   if (informCause) {
     cause = Cause.Null;
   }
   int inf = getLB();
   int sup = getUB();
   if (value == inf && value == sup) {
     this.contradiction(cause, AbstractVariable.MSG_REMOVE);
   } else if (inf == value || value == sup) {
     EventType e;
     if (value == inf) {
       // todo: delta...
       LB.set(value + 1);
       e = EventType.INCLOW;
       if (cause.reactOnPromotion()) {
         cause = Cause.Null;
       }
       if (A.getLB() > B.getUB()) {
         A.updateLowerBound(value + 1, this, false);
       }
       if (B.getLB() > A.getUB()) {
         B.updateLowerBound(value + 1, this, false);
       }
     } else {
       // todo: delta...
       UB.set(value - 1);
       e = EventType.DECUPP;
       if (cause.reactOnPromotion()) {
         cause = Cause.Null;
       }
       A.updateUpperBound(value - 1, this, false);
       B.updateUpperBound(value - 1, this, false);
     }
     if (SIZE.get() > 0) {
       if (this.instantiated()) {
         e = EventType.INSTANTIATE;
         if (cause.reactOnPromotion()) {
           cause = Cause.Null;
         }
       }
       this.notifyPropagators(e, cause);
     } else if (SIZE.get() == 0) {
       this.contradiction(cause, MSG_EMPTY);
     }
     return true;
   }
   return false;
 }
Esempio n. 27
0
  @Override
  public void backPropagate(int mask) throws ContradictionException {
    // one of the variable as changed externally, this involves a complete update of this
    // one of the variable as changed externally, this involves a complete update of this
    if (!EventType.isRemove(mask)) {
      int lA = A.getLB(), uA = A.getUB();
      int lB = B.getLB(), uB = B.getUB();

      int elb = Math.max(lA, lB);
      int eub = Math.max(uA, uB);

      int ilb = LB.get();
      int iub = UB.get();
      boolean change = false;
      EventType e = EventType.VOID;
      if (elb > ilb) {
        if (elb > iub) {
          this.contradiction(this, MSG_LOW);
        }
        SIZE.add(elb - ilb);
        ilb = elb;
        LB.set(ilb);
        e = EventType.INCLOW;
        change = true;
      }
      if (eub < iub) {
        if (eub < ilb) {
          this.contradiction(this, MSG_LOW);
        }
        SIZE.add(eub - iub);
        iub = eub;
        UB.set(iub);
        if (e != EventType.VOID) {
          e = EventType.BOUND;
        } else {
          e = EventType.DECUPP;
        }
        change |= true;
      }
      if (ilb > iub) {
        this.contradiction(this, MSG_EMPTY);
      }
      if (change) {
        if (ilb == iub) {
          notifyPropagators(EventType.INSTANTIATE, this);
        } else {
          notifyPropagators(e, this);
        }
      }
    }
  }
Esempio n. 28
0
  @Test
  public void shouldHaveTwoItemsInScopeMapAfterOnCreate() throws Exception {
    final ActivityController<B> bController = Robolectric.buildActivity(B.class);
    final B b = bController.get();

    assertThat(b.getScopedObjectMap().size(), equalTo(0));
    bController.create();

    boolean found = false;
    for (Object o : b.getScopedObjectMap().values()) if (o == b) found = true;

    assertTrue("Couldn't find context in scope map", found);
    assertTrue(b.getScopedObjectMap().containsKey(Key.get(C.class)));
  }
  @Test
  @TestForIssue(jiraKey = "HHH-5472")
  public void testCascade() {
    A a = new A();
    B b = new B();
    C c = new C();
    D d = new D();
    E e = new E();
    F f = new F();
    G g = new G();
    H h = new H();

    a.getBCollection().add(b);
    b.setA(a);

    a.getCCollection().add(c);
    c.setA(a);

    b.getCCollection().add(c);
    c.setB(b);

    a.getDCollection().add(d);
    d.getACollection().add(a);

    d.getECollection().add(e);
    e.setF(f);

    f.getBCollection().add(b);
    b.setF(f);

    c.setG(g);
    g.getCCollection().add(c);

    f.setH(h);
    h.setG(g);

    Session s;
    s = openSession();
    s.getTransaction().begin();
    try {
      // Fails: says that C.b is null (even though it isn't). Doesn't fail if you persist c, g or h
      // instead of a
      s.persist(a);
      s.flush();
    } finally {
      s.getTransaction().rollback();
      s.close();
    }
  }
  public static void main(String[] args) {
    Processor proc = new StringSplitterProcessor();
    doSomethingWithUserInput(proc);
    doSomethingWithUserInput(new CommaRemovedFilterAdapter());
    // doSomethingWithUserInput( new CommaRemovedFilter() );

    B b = new B();
    b.meth();

    A a1;

    a1 = new A();

    a1.meth();
  }