Esempio n. 1
0
  private LinkedList<Long> getUpdateList() {
    LinkedList<Long> updateList = new LinkedList<Long>();
    LinkedList<Long> insertList = new LinkedList<Long>();
    boolean flag = false;
    if (debug) Log.d(TAG, "message:-> " + rdArray.toString());
    for (int i = 0; i < rdArray.length; i++) {
      flag = false;
      for (int j = 0; j < idMapMatrix.length; j++) {

        if (rdArray[i].getLocal_id() == idMapMatrix[j][ID_MAP_MATRIX_LOCAL_ID]) {
          flag = true;

          updateList.add(rdArray[i].getLocal_id());
          if (debug)
            Log.d(TAG, "updating the list updateList with id: " + rdArray[i].getLocal_id());
          break;
        }
      }

      if (!flag) {
        insertList.add(rdArray[i].getLocal_id());
        // if (debug) Log.d(TAG, "inserting the list rdArray with id: "+rdArray[i].getLocal_id());
      }
    }

    return updateList;
  }
Esempio n. 2
0
 private List<Number> initList(LinkedList<Number> list) {
   list.add(new Double(1000f));
   list.add(new Double("123e-445632"));
   list.add(new Float(-90 / -3));
   list.remove(new Double("123e-445632"));
   return list;
 }
 @Test(timeout = 5 * 60 * 1000)
 public void testJNIMemoryManagerHeapExpansion() {
   LinkedList<RefCountedTester> heldRefs = new LinkedList<RefCountedTester>();
   JNIMemoryManager mgr = JNIMemoryManager.getMgr();
   mgr.flush();
   mgr.setMinimumReferencesToCache(1024);
   int maxItems = 10000;
   // 10000 should cause several heap expansions to occur
   for (int i = 0; i < maxItems; i++) {
     heldRefs.add(RefCountedTester.make());
   }
   assertEquals("didn't pin as many as it should", maxItems, mgr.getNumPinnedObjects());
   // now release them.
   heldRefs.clear();
   while (mgr.getNumPinnedObjects() != 0) {
     MemoryTestHelper.forceJavaHeapWeakReferenceClear();
     // Do a collection
     mgr.gc(true);
   }
   assertEquals("didn't pin as many as it should", 0, mgr.getNumPinnedObjects());
   // this should cause the heap to shrink, and then grow
   for (int i = 0; i < maxItems / 2; i++) {
     heldRefs.add(RefCountedTester.make());
   }
   assertEquals("didn't pin as many as it should", maxItems / 2, mgr.getNumPinnedObjects());
   // now release them.
   heldRefs.clear();
   // and force a collection
   while (mgr.getNumPinnedObjects() != 0) {
     MemoryTestHelper.forceJavaHeapWeakReferenceClear();
     // Do a collection
     mgr.gc(true);
   }
   assertEquals("didn't pin as many as it should", 0, mgr.getNumPinnedObjects());
 }
  /**
   * Creates toolbars for the application. This class always returns an empty list. Subclasses may
   * return other values.
   */
  @Override
  public List<JToolBar> createToolBars(Application a, @Nullable View pr) {
    ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels");
    DrawView p = (DrawView) pr;

    DrawingEditor editor;
    if (p == null) {
      editor = getSharedEditor();
    } else {
      editor = p.getEditor();
    }

    LinkedList<JToolBar> list = new LinkedList<JToolBar>();
    JToolBar tb;
    tb = new JToolBar();
    addCreationButtonsTo(tb, editor);
    tb.setName(labels.getString("window.drawToolBar.title"));
    list.add(tb);
    tb = new JToolBar();
    ButtonFactory.addAttributesButtonsTo(tb, editor);
    tb.setName(labels.getString("window.attributesToolBar.title"));
    list.add(tb);
    tb = new JToolBar();
    ButtonFactory.addAlignmentButtonsTo(tb, editor);
    tb.setName(labels.getString("window.alignmentToolBar.title"));
    list.add(tb);
    return list;
  }
 static void testObjectSensitivity1() {
   LinkedList<String> list1 = new LinkedList<String>();
   LinkedList<String> list2 = new LinkedList<String>();
   list1.add(taintedString("abcd")); // source
   list2.add("123");
   assert (getTaint(list2.getFirst()) == 0);
 }
Esempio n. 6
0
 /**
  * Remove all empty and {@code null} string elements from the given <var>names</var> and
  * optionally all redundant information like "." and "..".
  *
  * @param names names to check
  * @param canonical if {@code true}, remove redundant elements as well.
  * @return a possible empty array of names all with a length &gt; 0.
  */
 private static String[] normalize(String[] names, boolean canonical) {
   LinkedList<String> res = new LinkedList<String>();
   if (names == null || names.length == 0) {
     return new String[0];
   }
   for (int i = 0; i < names.length; i++) {
     if (names[i] == null || names[i].length() == 0) {
       continue;
     }
     if (canonical) {
       if (names[i].equals("..")) {
         if (!res.isEmpty()) {
           res.removeLast();
         }
       } else if (names[i].equals(".")) {
         continue;
       } else {
         res.add(names[i]);
       }
     } else {
       res.add(names[i]);
     }
   }
   return res.size() == names.length ? names : res.toArray(new String[res.size()]);
 }
Esempio n. 7
0
 /**
  * Add a new event to the eventQueue where it belongs determined first by its timestamp, then by
  * its priority if timestamps are equal
  *
  * @param newEvent
  */
 public void raise(Event newEvent) {
   int i = 0;
   for (Event event : eventQueue) {
     if (newEvent.timestamp > event.timestamp) {
       eventQueue.add(i, newEvent);
       if (Replay.recording) {
         Replay.saveEvent(newEvent);
       }
       break;
     } else if (newEvent.timestamp < event.timestamp) {
       continue;
     } else if (newEvent.priority >= event.priority) { // timestamps are equal, check priority
       eventQueue.add(i, newEvent);
       if (Replay.recording) {
         Replay.saveEvent(newEvent);
       }
       break;
     }
     i++;
   }
   if (i == eventQueue.size()) {
     eventQueue.addLast(newEvent);
     if (Replay.recording) {
       Replay.saveEvent(newEvent);
     }
   }
 }
Esempio n. 8
0
  private void writeVerifyPack4(final boolean thin) throws IOException {
    final LinkedList<ObjectId> interestings = new LinkedList<ObjectId>();
    interestings.add(ObjectId.fromString("82c6b885ff600be425b4ea96dee75dca255b69e7"));
    final LinkedList<ObjectId> uninterestings = new LinkedList<ObjectId>();
    uninterestings.add(ObjectId.fromString("c59759f143fb1fe21c197981df75a7ee00290799"));
    createVerifyOpenPack(interestings, uninterestings, thin, false);

    final ObjectId writtenObjects[] =
        new ObjectId[] {
          ObjectId.fromString("82c6b885ff600be425b4ea96dee75dca255b69e7"),
          ObjectId.fromString("aabf2ffaec9b497f0950352b3e582d73035c2035"),
          ObjectId.fromString("5b6e7c66c276e7610d4a73c70ec1a1f7c1003259")
        };
    assertEquals(writtenObjects.length, writer.getObjectsNumber());
    ObjectId expectedObjects[];
    if (thin) {
      expectedObjects = new ObjectId[4];
      System.arraycopy(writtenObjects, 0, expectedObjects, 0, writtenObjects.length);
      expectedObjects[3] = ObjectId.fromString("6ff87c4664981e4397625791c8ea3bbb5f2279a3");

    } else {
      expectedObjects = writtenObjects;
    }
    verifyObjectsOrder(expectedObjects);
    assertEquals("cded4b74176b4456afa456768b2b5aafb41c44fc", writer.computeName().name());
  }
  public void testAssociation() {

    LinkedList<Assertion> asserts = new LinkedList();
    asserts.add(Assertion.create("John lives around here."));
    asserts.add(Assertion.create("Mary lives around here."));
    asserts.add(Assertion.create("Simon lives around here."));
    asserts.add(Assertion.create("Mary lives in the blue house."));
    asserts.add(Assertion.create("The plumber lives in the yellow house."));
    asserts.add(Assertion.create("The carpenter lives around here."));

    PuzzleSolver testS = new PuzzleSolver(asserts);

    PermutationPairs testP = new PermutationPairs(3);

    String[][] possibility = testS.associatePermsWithStrings(testP.nextPair());

    assertEquals("John", possibility[0][0]);
    assertEquals("plumber", possibility[0][1]);
    assertEquals("blue", possibility[0][2]);

    assertEquals("Mary", possibility[1][0]);
    assertEquals("carpenter", possibility[1][1]);
    assertEquals("yellow", possibility[1][2]);

    assertEquals("Simon", possibility[2][0]);
    assertEquals("#u", possibility[2][1]);
    assertEquals("#u", possibility[2][2]);
  }
Esempio n. 10
0
  /**
   * On créé le paquet de cartes Kokus
   *
   * @return
   */
  public LinkedList<Kokus> initialisationPaquetKokus() {
    LinkedList<Kokus> llk = new LinkedList<Kokus>();

    for (Kokus k : this.hashKokus) {
      // 12 cartes kokus de 1 unité
      if (k.getNbkoku() == 1) {
        for (int i = 0; i < 12; i++) {
          llk.add(k);
        }
      }

      // 8 cartes kokus de 2 unités
      if (k.getNbkoku() == 2) {
        for (int i = 0; i < 8; i++) {
          llk.add(k);
        }
      }

      // 4 cartes kokus de 3 unités
      if (k.getNbkoku() == 3) {
        for (int i = 0; i < 4; i++) {
          llk.add(k);
        }
      }
    }
    Collections.shuffle(llk);

    return llk;
  }
Esempio n. 11
0
  private void writeVerifyPack2(boolean deltaReuse) throws IOException {
    writer.setReuseDeltas(deltaReuse);
    final LinkedList<ObjectId> interestings = new LinkedList<ObjectId>();
    interestings.add(ObjectId.fromString("82c6b885ff600be425b4ea96dee75dca255b69e7"));
    final LinkedList<ObjectId> uninterestings = new LinkedList<ObjectId>();
    uninterestings.add(ObjectId.fromString("540a36d136cf413e4b064c2b0e0a4db60f77feab"));
    createVerifyOpenPack(interestings, uninterestings, false, false);

    final ObjectId expectedOrder[] =
        new ObjectId[] {
          ObjectId.fromString("82c6b885ff600be425b4ea96dee75dca255b69e7"),
          ObjectId.fromString("c59759f143fb1fe21c197981df75a7ee00290799"),
          ObjectId.fromString("aabf2ffaec9b497f0950352b3e582d73035c2035"),
          ObjectId.fromString("902d5476fa249b7abc9d84c611577a81381f0327"),
          ObjectId.fromString("5b6e7c66c276e7610d4a73c70ec1a1f7c1003259"),
          ObjectId.fromString("6ff87c4664981e4397625791c8ea3bbb5f2279a3")
        };
    if (deltaReuse) {
      // objects order influenced (swapped) by delta-base first rule
      ObjectId temp = expectedOrder[4];
      expectedOrder[4] = expectedOrder[5];
      expectedOrder[5] = temp;
    }
    assertEquals(expectedOrder.length, writer.getObjectsNumber());
    verifyObjectsOrder(expectedOrder);
    assertEquals("ed3f96b8327c7c66b0f8f70056129f0769323d86", writer.computeName().name());
  }
Esempio n. 12
0
  /**
   * On créé la paquet de carte Troupes
   *
   * @return
   */
  public LinkedList<CarteTroupe> initialisationPaquetTroupe() {
    LinkedList<CarteTroupe> llct = new LinkedList<CarteTroupe>();
    int i = 1;

    for (Troupes t : hashTroupes) {
      CarteTroupe ct = new CarteTroupe(t);
      // On met 6 fois la même carte dans la liste
      for (int k = 0; k < 6; k++) {
        llct.add(ct);
      }
      // il faut également mettre un carte avec deux troupes (en tout 6 cartes)
      int j = 1;
      for (Troupes t2 : hashTroupes) {
        // On ne reprend pas les cartes précédentes (elles ont déjà ét traitées)
        if (i == j || i < j) {
          CarteTroupe ct2 = new CarteTroupe(t, t2);
          llct.add(ct2);
        }
        j++;
      }
      i++;
    }
    // On mélange le paquet
    Collections.shuffle(llct);

    return llct;
  }
Esempio n. 13
0
 public static String[] minus(String[] arr1, String[] arr2) {
   LinkedList<String> list = new LinkedList<String>();
   LinkedList<String> history = new LinkedList<String>();
   String[] longerArr = arr1;
   String[] shorterArr = arr2;
   // 找出较长的数组来减较短的数组
   //        if (arr1.length > arr2.length) {
   //            longerArr = arr2;
   //            shorterArr = arr1;
   //        }
   for (String str : longerArr) {
     if (!list.contains(str)) {
       list.add(str);
     }
   }
   for (String str : shorterArr) {
     if (list.contains(str)) {
       history.add(str);
       list.remove(str);
     } else {
       if (!history.contains(str)) {
         list.add(str);
       }
     }
   }
   String[] result = {};
   return list.toArray(result);
 }
  /* (non-Javadoc)
   * @see org.apache.batik.parser.PathHandler#curvetoCubicSmoothAbs(float, float, float, float)
   */
  public void curvetoCubicSmoothAbs(float x2, float y2, float x, float y) throws ParseException {
    if (verbose)
      System.out.println("curvetoCubicSmoothAbs x2:" + x2 + " y2:" + y2 + " x:" + x + " y:" + y);

    Vertex lastPoint = pathPoints.getLast();
    if (lastPoint instanceof BezierVertex) {
      BezierVertex lastBez = (BezierVertex) lastPoint;

      Vertex lastConPointCopy = (Vertex) lastBez.getSecondCtrlPoint().getCopy();
      // reflect the last controlpoint at the current point
      lastConPointCopy.rotateZ(lastPoint, 180);
      BezierVertex b =
          new BezierVertex(lastConPointCopy.getX(), lastConPointCopy.getY(), 0, x2, y2, 0, x, y, 0);

      pathPoints.add(b);
      currentSubPath.add(b);
    } else {
      if (verbose)
        System.out.println(
            "Couldnt get last controlpoint at: curvetoCubicSmoothAbs - using last point as first controlpoint");

      Vertex lastEndPoint = new Vertex(lastPoint.getX(), lastPoint.getY(), 0);
      BezierVertex b =
          new BezierVertex(lastEndPoint.getX(), lastEndPoint.getY(), 0, x2, y2, 0, x, y, 0);

      pathPoints.add(b);
      currentSubPath.add(b);
    }
  }
Esempio n. 15
0
 /** @generated */
 public List<IElementType> getMATypesForTarget(IElementType relationshipType) {
   LinkedList<IElementType> types = new LinkedList<IElementType>();
   if (relationshipType == Neuro4jElementTypes.OperatorInput_4009) {
     types.add(Neuro4jElementTypes.OperatorOutput_2016);
     types.add(Neuro4jElementTypes.OperatorOutput_3001);
     types.add(Neuro4jElementTypes.OperatorOutput_3002);
     types.add(Neuro4jElementTypes.OperatorOutput_3003);
     types.add(Neuro4jElementTypes.OperatorOutput_3004);
     types.add(Neuro4jElementTypes.OperatorOutput_3010);
     types.add(Neuro4jElementTypes.OperatorOutput_3011);
     types.add(Neuro4jElementTypes.OperatorOutput_3012);
     types.add(Neuro4jElementTypes.OperatorOutput_3013);
   } else if (relationshipType == Neuro4jElementTypes.OperatorOutput_4008) {
     // types.add(Neuro4jElementTypes.DecisionNode_2007);
     // types.add(Neuro4jElementTypes.FollowByRelationNode_2011);
     // types.add(Neuro4jElementTypes.LoopNode_2006);
     // types.add(Neuro4jElementTypes.CallNode_2008);
     // types.add(Neuro4jElementTypes.EndNode_2005);
     // types.add(Neuro4jElementTypes.MapperNode_2010);
     // types.add(Neuro4jElementTypes.LogicNode_2017);
     // types.add(Neuro4jElementTypes.JoinNode_2002);
     // types.add(Neuro4jElementTypes.StartNode_2004);
     // types.add(Neuro4jElementTypes.ViewNode_2018);
   }
   return types;
 }
Esempio n. 16
0
  private void rebentaEstrela(Estrela estrela) {

    ArrayList<Estrela> estrelasARemover = null;
    ArrayList<Estrela> estrelasAAdicionar = null;

    if (estrelasARemover == null) {
      estrelasARemover = new ArrayList<>();
    }
    estrelasARemover.add(estrela);
    int diametroAtual = estrela.getDiametro();
    if (estrela.getDiametro() > 20) {
      if (estrelasAAdicionar == null) {
        estrelasAAdicionar = new ArrayList<>();
      }
      estrelasAAdicionar.add(estrela.criaMenor(diametroAtual - 20, false));
      estrelasAAdicionar.add(estrela.criaMenor(diametroAtual - 20, true));
    }

    if (estrelasARemover != null) {
      for (Estrela estrelaARemover : estrelasARemover) {
        estrelas.remove(estrelaARemover);
        pintaveis.remove(estrelaARemover);
      }
    }
    if (estrelasAAdicionar != null) {
      for (Estrela estrelaAAdicionar : estrelasAAdicionar) {
        estrelas.add(estrelaAAdicionar);
        pintaveis.add(estrelaAAdicionar);
      }
    }
    if (estrelas.isEmpty() && bolas.isEmpty()) fimNivel();
  }
Esempio n. 17
0
  private void convertToDFA(NFA nfa) {
    DFAState curr, temp;
    List<String> tokens = new ArrayList<String>();
    LinkedList<DFAState> queue = new LinkedList<DFAState>();
    findStart(nfa);
    queue.add(start);

    MAINWHILE:
    while (!queue.isEmpty()) {
      curr = queue.removeFirst();
      for (DFAState sta : checked) {
        if (curr.equals(sta)) {
          //            		System.out.println("NOPE");
          continue MAINWHILE;
        }
      }
      checked.add(curr);
      // Pull out all keys
      for (State s : curr.getStates()) {
        for (String k : s.getTransitionTable().keySet()) {
          tokens.add(k);
          // System.out.println(tokens);
        }
      }
      // Iterate over all possible iterations and link states together
      for (String j : tokens) {
        if (!j.equals("")) {
          temp = goTo(curr, j);
          queue.add(temp);
        }
      }
    }
  }
Esempio n. 18
0
  private void tempoEsgotado() {
    vidas.inc(-1);
    if (vidas.getValor() == 0) {
      fimDoJogo();
      return;
    }

    TXTPaint tempoEsgotado = new TXTPaint(criaFonte(Font.PLAIN, 40), "Tempo esgotado");
    tempoEsgotado.setX(250);
    tempoEsgotado.setY(300);

    tempoEsgotado.setVisivel(true);

    pintaveis.clear();
    pintaveis.add(fundo);
    pintaveis.add(tempoEsgotado);

    temporizar(
        new Inteiro(3),
        new Runnable() {
          public void run() {
            carregarNivel();
          }
        });
  }
Esempio n. 19
0
 public void printLoop(int n, float x[], float y[]) {
   // Need to swap the y component
   Polygon P = new Polygon();
   for (int i = 0; i < n; i++) P.addPoint(Math.round(x[i]), Math.round(height - y[i]));
   poly_draw.add(P);
   poly_draw_color.add(curColor);
 }
Esempio n. 20
0
  private void fimDoJogo() {
    if (temporizador != null) {
      temporizador.stop();
      temporizador = null;
    }

    TXTPaintComSobra txtFimJogo = new TXTPaintComSobra(criaFonte(Font.BOLD, 40), "Fim do jogo");
    LinkedList<Pintavel> lPintaveis = new LinkedList<Pintavel>();
    lPintaveis.add(fundo);
    lPintaveis.add(txtFimJogo);
    txtFimJogo.setVisivel(true);
    temporizar(
        new Inteiro(3),
        new Runnable() {
          public void run() {
            continuarAnimacao.setValor(false);
            String nome = null;
            nome = JOptionPane.showInputDialog("Introduz o nome");
            if (nome != null) {
              BDTpontuacoes tPontuacoes = new BDTpontuacoes();
              try {
                tPontuacoes.inserirUtilizador(nome, pontos);
              } catch (SQLException ex) {
                JOptionPane.showMessageDialog(
                    null, ex.getMessage(), "Erro SQL", JOptionPane.ERROR_MESSAGE);
              } finally {
                tPontuacoes.fecha();
              }
            }
          }
        });
    pintaveis = lPintaveis;
  }
Esempio n. 21
0
  public static @NonNull LinkedList<ThemeInfo> enumerateThemes(@NonNull Context context) {
    LinkedList<ThemeInfo> themes = new LinkedList<>();
    AssetManager manager = context.getAssets();

    // load themes from assets
    try {
      String[] builtin_themes = manager.list("");
      for (String theme : builtin_themes) {
        if (!theme.toLowerCase().endsWith("theme.properties")) continue;
        Properties p = loadColorScheme(theme, manager);
        if (p != null) themes.add(new ThemeInfo(p.getProperty("NAME", theme), theme));
      }
    } catch (IOException e) {
      e.printStackTrace();
    }

    // load themes from disk
    File dir = new File(SEARCH_DIR);
    if (dir.exists()) {
      File[] files = dir.listFiles();
      if (files != null) {
        for (File file : files) {
          if (!file.getName().toLowerCase().endsWith("theme.properties")) continue;
          Properties p = loadColorScheme(file.getAbsolutePath(), null);
          if (p != null)
            themes.add(
                new ThemeInfo(p.getProperty("NAME", file.getName()), file.getAbsolutePath()));
        }
      }
    }
    return themes;
  }
 public void addState(World x) {
   double growthRate = calGrowthRate(x), deathRate = calDeathRate(x);
   int population = x.getPopulation();
   listPopulationChange.add(generation == 0 ? population : population - listPopulation.getLast());
   listPopulation.add(population);
   listGrowthRate.add(growthRate);
   listDeathRate.add(deathRate);
   if (generation == 1) {
     minPopulation = maxPopulation = population;
     maxGrowthRate = minGrowthRate = growthRate;
     maxDeathRate = deathRate;
     maxPopulationChange = minPopulationChange = listPopulationChange.getLast();
   }
   if (generation > 1) {
     minPopulation = minPopulation > population ? population : minPopulation;
     maxPopulation = maxPopulation < population ? population : maxPopulation;
     maxGrowthRate = maxGrowthRate < growthRate ? growthRate : maxGrowthRate;
     maxDeathRate = maxDeathRate < deathRate ? deathRate : maxDeathRate;
     maxPopulationChange = Math.max(maxPopulationChange, listPopulationChange.getLast());
     minPopulationChange = Math.min(minPopulationChange, listPopulationChange.getLast());
     maxGrowthRate = Math.max(maxGrowthRate, listGrowthRate.getLast());
     minGrowthRate = Math.min(minGrowthRate, listGrowthRate.getLast());
   }
   generation++;
   listCells.add(x);
 }
Esempio n. 23
0
 public static List getLatestFeed() throws Exception {
   YouTubeService service = new YouTubeService("MangaWire");
   YouTubeQuery query = new YouTubeQuery(new URL("http://gdata.youtube.com/feeds/api/videos"));
   query.setAuthor("Ulquiorra43");
   query.setOrderBy(OrderBy.PUBLISHED);
   query.setSafeSearch(SafeSearch.STRICT);
   VideoFeed feed = service.query(query, VideoFeed.class);
   System.out.println("Number of entries: " + feed.getEntries().size());
   LinkedList<VideoEntry> videoList = new LinkedList<VideoEntry>();
   if (feed.getEntries().size() < MAX_RESULTS) {
     for (int i = 0; i < feed.getEntries().size(); i++) {
       if (feed.getEntries().get(i).getMediaGroup().getYouTubeContents().isEmpty()) {
         // DO NOTHING
       } else {
         videoList.add(feed.getEntries().get(i));
       }
     }
   } else {
     for (int i = 0; i < MAX_RESULTS; i++) {
       if (feed.getEntries().get(i).getMediaGroup().getYouTubeContents().isEmpty()) {
         // DO NOTHING
       } else {
         videoList.add(feed.getEntries().get(i));
       }
     }
   }
   return videoList;
 }
 @Override
 public Collection<Node> getOperands() {
   LinkedList<Node> list = new LinkedList<Node>();
   list.add(getLeftOperand());
   list.add(getRightOperand());
   return list;
 }
 /**
  * Overriden superclass method. Calls super.init() and also initializes the MuleContext
  *
  * @see SpringServicesContainer#init()
  */
 public void init() throws PlatformException {
   super.init();
   LinkedList<String> fileNamesList = new LinkedList<String>();
   // add the common Mule beans file
   fileNamesList.add(SedaFrameworkConstants.COMMON_MULE_CONFIG);
   // add the Mule configurations containing Mule service definitions
   File[] serviceBeansFiles = FileLocator.findFiles(SedaFrameworkConstants.MULE_CONFIG);
   for (File serviceBeansFile : serviceBeansFiles) {
     fileNamesList.add(serviceBeansFile.getAbsolutePath());
   }
   String[] muleConfigPaths = (String[]) fileNamesList.toArray(new String[0]);
   try {
     SpringXmlConfigurationBuilder springConfigBuilder =
         new SpringXmlConfigurationBuilder(muleConfigPaths);
     springConfigBuilder.setUseDefaultConfigResource(
         false); // turn off using the default config resource as we have a custom config defined
     // in SedaFrameworkConstants.COMMON_MULE_CONFIG
     springConfigBuilder.setParentContext(this.servicesContext);
     this.muleContext = new DefaultMuleContextFactory().createMuleContext(springConfigBuilder);
     this.muleContext.start();
   } catch (Exception e) {
     LOGGER.error("Fatal error loading Mule configurations : " + e.getMessage(), e);
     throw new PlatformException("Fatal error loading Mule configurations : " + e.getMessage(), e);
   }
 }
Esempio n. 26
0
  public Importer(NetworkParameters params, Jelectrum jelly, BlockStore block_store)
      throws com.google.bitcoin.store.BlockStoreException {
    this.jelly = jelly;
    this.params = params;
    this.file_db = jelly.getDB();
    this.block_store = (MapBlockStore) block_store;

    Config config = jelly.getConfig();
    config.require("block_save_threads");
    config.require("transaction_save_threads");

    block_queue = new LinkedBlockingQueue<Block>(32);
    tx_queue = new LinkedBlockingQueue<TransactionWork>(4096);
    transaction_cache = new LRUCache<Sha256Hash, Transaction>(100000);

    in_progress = new LRUCache<Sha256Hash, Semaphore>(1024);

    save_thread_list = new LinkedList<StatusContext>();
    for (int i = 0; i < config.getInt("block_save_threads"); i++) {
      BlockSaveThread t = new BlockSaveThread();
      save_thread_list.add(t);
      t.start();
    }

    for (int i = 0; i < config.getInt("transaction_save_threads"); i++) {
      TransactionSaveThread t = new TransactionSaveThread();
      save_thread_list.add(t);
      t.start();
    }

    putInternal(params.getGenesisBlock());

    // checkConsistency();

  }
Esempio n. 27
0
  @RequestMapping(value = "/customerTips", method = RequestMethod.GET)
  public ModelAndView customerTips(@RequestParam("uid") UserIdentifier uid) {
    ModelAndView mav = new ModelAndView();
    Customer currentCustomer = (Customer) GmbPersistenceManager.get(uid);
    mav.setViewName("customer/tips/tip_customerTips");

    LinkedList<WeeklyLottoSTT> weeklySTTList = new LinkedList<WeeklyLottoSTT>();
    LinkedList<TotoSTT> totoSTTList = new LinkedList<TotoSTT>();
    LinkedList<DailyLottoSTT> dailyLottoSTTList = new LinkedList<DailyLottoSTT>();
    for (TotoSTT tSTT : currentCustomer.getTotoSTTs()) {
      if (!tSTT.getTip().getDraw().getEvaluated()) totoSTTList.add(tSTT);
    }
    for (DailyLottoSTT dLSTT : currentCustomer.getDailyLottoSTTs()) {
      if (!dLSTT.getTip().getDraw().getEvaluated()) dailyLottoSTTList.add(dLSTT);
    }
    for (WeeklyLottoSTT wLSTT : currentCustomer.getWeeklyLottoSTTs()) {
      if (!wLSTT.getTip().getDraw().getEvaluated()) weeklySTTList.add(wLSTT);
    }
    mav.addObject("weeklySTTList", (weeklySTTList.size() > 0) ? weeklySTTList : null);
    mav.addObject("totoSTTList", (totoSTTList.size() > 0) ? totoSTTList : null);
    mav.addObject("dailySTTList", (dailyLottoSTTList.size() > 0) ? dailyLottoSTTList : null);
    mav.addObject(
        "weeklyPTTList",
        (currentCustomer.getWeeklyLottoPTTs().size() > 0)
            ? currentCustomer.getWeeklyLottoPTTs()
            : null);
    mav.addObject(
        "dailyPTTList",
        (currentCustomer.getDailyLottoPTTs().size() > 0)
            ? currentCustomer.getDailyLottoPTTs()
            : null);
    mav.addObject("currentUser", currentCustomer);
    return mav;
  }
Esempio n. 28
0
 private LinkedList<Vector2f> calc(Field2D field, Vector2f start, Vector2f goal, boolean flag) {
   if (start.equals(goal)) {
     LinkedList<Vector2f> v = new LinkedList<Vector2f>();
     v.add(start);
     return v;
   }
   this.goal = goal;
   if (visitedCache == null) {
     visitedCache = new HashSet<Vector2f>();
   } else {
     visitedCache.clear();
   }
   if (pathes == null) {
     pathes = new LinkedList<ScoredPath>();
   } else {
     pathes.clear();
   }
   visitedCache.add(start);
   if (path == null) {
     path = new LinkedList<Vector2f>();
   } else {
     path.clear();
   }
   path.add(start);
   if (spath == null) {
     spath = new ScoredPath(0, path);
   } else {
     spath.score = 0;
     spath.path = path;
   }
   pathes.add(spath);
   return astar(field, flag);
 }
  public RC3500_A_IP44_DE(
      Context context, Long id, String name, LinkedList<Boolean> dips, Long roomId) {
    super(context, id, name, BRAND, MODEL, TYPE_DIPS, roomId);
    dipList = new LinkedList<>();

    if (dips != null && dips.size() == 10) {
      dipList.add(new DipSwitch("1", dips.get(0)));
      dipList.add(new DipSwitch("2", dips.get(1)));
      dipList.add(new DipSwitch("3", dips.get(2)));
      dipList.add(new DipSwitch("4", dips.get(3)));
      dipList.add(new DipSwitch("5", dips.get(4)));
      dipList.add(new DipSwitch("A", dips.get(5)));
      dipList.add(new DipSwitch("B", dips.get(6)));
      dipList.add(new DipSwitch("C", dips.get(7)));
      dipList.add(new DipSwitch("D", dips.get(8)));
      dipList.add(new DipSwitch("E", dips.get(9)));
    } else {
      dipList.add(new DipSwitch("1", false));
      dipList.add(new DipSwitch("2", false));
      dipList.add(new DipSwitch("3", false));
      dipList.add(new DipSwitch("4", false));
      dipList.add(new DipSwitch("5", false));
      dipList.add(new DipSwitch("A", false));
      dipList.add(new DipSwitch("B", false));
      dipList.add(new DipSwitch("C", false));
      dipList.add(new DipSwitch("D", false));
      dipList.add(new DipSwitch("E", false));
    }

    buttons.add(new Button(Button.BUTTON_ON_ID, context.getString(R.string.on), id));
    buttons.add(new Button(Button.BUTTON_OFF_ID, context.getString(R.string.off), id));
  }
Esempio n. 30
0
 // a nearest neighbor in the set to point p; null if the set is empty
 public Point2D nearest(Point2D p) {
   if (null == p) {
     throw new java.lang.NullPointerException();
   }
   if (this.isEmpty()) {
     return null;
   }
   Point2D res = null;
   double dis = Double.MAX_VALUE;
   LinkedList<Node> q = new LinkedList<Node>();
   q.add(root);
   while (!q.isEmpty()) {
     Node tp = q.pollFirst();
     double cur = p.distanceSquaredTo(tp.getP());
     if (cur < dis) {
       dis = cur;
       res = tp.getP();
     }
     Node lch = tp.getLb();
     Node rch = tp.getRt();
     if (null != lch && lch.getRect().distanceSquaredTo(p) < dis) {
       q.add(lch);
     }
     if (null != rch && rch.getRect().distanceSquaredTo(p) < dis) {
       q.add(rch);
     }
   }
   return res;
 }