Package java.util

Examples of java.util.PriorityQueue


    return localPriorityBlockingQueue;
  }

  public static PriorityQueue newPriorityQueue()
  {
    return new PriorityQueue();
  }
View Full Code Here


  }

  public static PriorityQueue newPriorityQueue(Iterable paramIterable)
  {
    if ((paramIterable instanceof Collection))
      return new PriorityQueue(Collections2.cast(paramIterable));
    PriorityQueue localPriorityQueue = new PriorityQueue();
    Iterables.addAll(localPriorityQueue, paramIterable);
    return localPriorityQueue;
  }
View Full Code Here

   
    //System.out.println("Number of children="+traversalTree.getChildCount());
   
    String date = null;
   
    PriorityQueue queue = new PriorityQueue();
 
    while (enu.hasMoreElements())
    {
      DefaultMutableTreeNode node = (DefaultMutableTreeNode)enu.nextElement();
      if (node.isLeaf())
      {
        //System.out.println("Is leaf");
        //System.out.println("Name="+node.getUserObject());
        NameQueryNode nqn = (NameQueryNode)node.getUserObject();
       
        String buffername = nqn.getName();
        date = nqn.getDate();
        if (date == null)
        {
          date = "0000-00-00";
        }
       
        //System.out.println("Name="+buffername+" Date="+date);
        //System.out.println("date="+date);
        if (buffername!=null)
        {
          queue.add(new SortNameUnit(date,buffername));
        }
       
      }
    }
   
    //ExceptionGroup exceptionThreadGroup = new ExceptionGroup();
    Iterator iter = queue.iterator();
   
    System.out.println("The number of buffers to be optimized in repository '"+repos+"' = "+queue.size()+".");
   
    this.optimizing_threads = 0;
    while (iter.hasNext())
    {
      SortNameUnit unit = (SortNameUnit)iter.next();
View Full Code Here

   
    //System.out.println("Number of children="+traversalTree.getChildCount());
   
    String date = null;
   
    PriorityQueue queue = new PriorityQueue();
 
    while (enu.hasMoreElements())
    {
      DefaultMutableTreeNode node = (DefaultMutableTreeNode)enu.nextElement();
      if (node.isLeaf())
      {
        //System.out.println("Is leaf");
        //System.out.println("Name="+node.getUserObject());
        NameQueryNode nqn = (NameQueryNode)node.getUserObject();
       
        String buffername = nqn.getName();
        date = nqn.getDate();
        if (date == null)
        {
          date = "0000-00-00";
        }
       
        //System.out.println("Name="+buffername+" Date="+date);
        //System.out.println("date="+date);
        if (buffername!=null)
        {
          queue.add(new SortNameUnit(date,buffername));
        }
       
      }
    }
   
    //ExceptionGroup exceptionThreadGroup = new ExceptionGroup();
    Iterator iter = queue.iterator();
   
    System.out.println("The number of buffers to be optimized in repository '"+repos+"' = "+queue.size()+".");
   
    this.optimizing_threads = 0;
    while (iter.hasNext())
    {
      SortNameUnit unit = (SortNameUnit)iter.next();
View Full Code Here

    while (nextClass != null) {
      Collections.addAll(allMethods, nextClass.getDeclaredMethods());
      nextClass = nextClass.getSuperclass();
      if (nextClass == Object.class) break;
    }
    PriorityQueue<Method> methods = new PriorityQueue(Math.max(1, allMethods.size()), new Comparator<Method>() {
      public int compare (Method o1, Method o2) {
        // Methods are sorted so they can be represented as an index.
        int diff = o1.getName().compareTo(o2.getName());
        if (diff != 0) return diff;
        Class[] argTypes1 = o1.getParameterTypes();
        Class[] argTypes2 = o2.getParameterTypes();
        if (argTypes1.length > argTypes2.length) return 1;
        if (argTypes1.length < argTypes2.length) return -1;
        for (int i = 0; i < argTypes1.length; i++) {
          diff = argTypes1[i].getName().compareTo(argTypes2[i].getName());
          if (diff != 0) return diff;
        }
        throw new RuntimeException("Two methods with same signature!"); // Impossible.
      }
    });
    for (int i = 0, n = allMethods.size(); i < n; i++) {
      Method method = allMethods.get(i);
      int modifiers = method.getModifiers();
      if (Modifier.isStatic(modifiers)) continue;
      if (Modifier.isPrivate(modifiers)) continue;
      if (method.isSynthetic()) continue;
      methods.add(method);
    }

    int n = methods.size();
    cachedMethods = new CachedMethod[n];
    for (int i = 0; i < n; i++) {
      CachedMethod cachedMethod = new CachedMethod();
      cachedMethod.method = methods.poll();

      // Store the serializer for each final parameter.
      Class[] parameterTypes = cachedMethod.method.getParameterTypes();
      cachedMethod.serializers = new Serializer[parameterTypes.length];
      for (int ii = 0, nn = parameterTypes.length; ii < nn; ii++)
View Full Code Here

    final Array<Page> pages = new Array<Page>();
    final Array<Region> regions = new Array<Region>();

    public TextureAtlasData (FileHandle packFile, FileHandle imagesDir, boolean flip) {
      PriorityQueue<Region> sortedRegions = new PriorityQueue(16, indexComparator);

      BufferedReader reader = new BufferedReader(new InputStreamReader(packFile.read()), 64);
      try {
        Page pageImage = null;
        while (true) {
          String line = reader.readLine();
          if (line == null) break;
          if (line.trim().length() == 0)
            pageImage = null;
          else if (pageImage == null) {
            FileHandle file = imagesDir.child(line);

            Format format = Format.valueOf(readValue(reader));

            readTuple(reader);
            TextureFilter min = TextureFilter.valueOf(tuple[0]);
            TextureFilter max = TextureFilter.valueOf(tuple[1]);

            String direction = readValue(reader);
            TextureWrap repeatX = ClampToEdge;
            TextureWrap repeatY = ClampToEdge;
            if (direction.equals("x"))
              repeatX = Repeat;
            else if (direction.equals("y"))
              repeatY = Repeat;
            else if (direction.equals("xy")) {
              repeatX = Repeat;
              repeatY = Repeat;
            }

            pageImage = new Page(file, min.isMipMap(), format, min, max, repeatX, repeatY);
            pages.add(pageImage);
          } else {
            boolean rotate = Boolean.valueOf(readValue(reader));

            readTuple(reader);
            int left = Integer.parseInt(tuple[0]);
            int top = Integer.parseInt(tuple[1]);

            readTuple(reader);
            int width = Integer.parseInt(tuple[0]);
            int height = Integer.parseInt(tuple[1]);

            Region region = new Region();
            region.page = pageImage;
            region.left = left;
            region.top = top;
            region.width = width;
            region.height = height;
            region.name = line;
            region.rotate = rotate;

            readTuple(reader);
            region.originalWidth = Integer.parseInt(tuple[0]);
            region.originalHeight = Integer.parseInt(tuple[1]);

            readTuple(reader);
            region.offsetX = Integer.parseInt(tuple[0]);
            region.offsetY = Integer.parseInt(tuple[1]);

            region.index = Integer.parseInt(readValue(reader));

            if (flip) region.flip = true;

            sortedRegions.add(region);
          }
        }
      } catch (IOException ex) {
        throw new GdxRuntimeException("Error reading pack file: " + packFile);
      } finally {
        try {
          reader.close();
        } catch (IOException ignored) {
        }
      }

      int n = sortedRegions.size();
      for (int i = 0; i < n; i++)
        regions.add(sortedRegions.poll());
    }
View Full Code Here

            _reverse = reverse;
        }

        @Override
        public PriorityQueue init(Object batchId, TridentCollector collector) {
            return new PriorityQueue(_n, new Comparator<TridentTuple>() {
                @Override
                public int compare(TridentTuple t1, TridentTuple t2) {
                    Comparable c1 = (Comparable) t1.getValueByField(_sortField);
                    Comparable c2 = (Comparable) t2.getValueByField(_sortField);
                    int ret = c1.compareTo(c2);
View Full Code Here

TOP

Related Classes of java.util.PriorityQueue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.