当前位置: 首页>>代码示例>>Java>>正文


Java Collections.reverse方法代码示例

本文整理汇总了Java中java.util.Collections.reverse方法的典型用法代码示例。如果您正苦于以下问题:Java Collections.reverse方法的具体用法?Java Collections.reverse怎么用?Java Collections.reverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Collections的用法示例。


在下文中一共展示了Collections.reverse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSlices

import java.util.Collections; //导入方法依赖的package包/类
public List<Slice> getSlices(Slice cur, long range) {

        List<Integer> rangePoints = getPreRangePoint(cur, range);
        List<Slice> slices = new ArrayList<>();
        for (int point : rangePoints) {
            String key = CACHE_PREFIX + cur.getKey() + "_" + point;
            @SuppressWarnings("unchecked")
            List<String> rangeSlicesStr = cm.lrange(UAV_CACHE_REGION, key, 0, -1);
            if (rangeSlicesStr.isEmpty()) {
                continue;
            }
            for (String ss : rangeSlicesStr) {
                Slice s = new Slice(ss);
                slices.add(s);
            }
        }
        Collections.reverse(slices);
        return slices;
    }
 
开发者ID:uavorg,项目名称:uavstack,代码行数:20,代码来源:RuntimeNotifySliceMgr.java

示例2: reverseIterationIsInOrder

import java.util.Collections; //导入方法依赖的package包/类
@Test
public void reverseIterationIsInOrder() {
  for (Map<Integer, Integer> any : someMaps(integers(), integers())) {
    List<Integer> expectedKeys = new ArrayList<>(any.keySet());
    Collections.sort(expectedKeys);
    Collections.reverse(expectedKeys);

    ImmutableSortedMap<Integer, Integer> map = RBTreeSortedMap.fromMap(any, IntComparator);
    List<Integer> actualKeys = new ArrayList<>();
    Iterator<Map.Entry<Integer, Integer>> iterator = map.reverseIterator();
    while (iterator.hasNext()) {
      actualKeys.add(iterator.next().getKey());
    }

    assertEquals(expectedKeys, actualKeys);
  }
}
 
开发者ID:firebase,项目名称:firebase-admin-java,代码行数:18,代码来源:RBTreeSortedMapTest.java

示例3: main

import java.util.Collections; //导入方法依赖的package包/类
public static void main(String[] args) {

    //create a Vector object
    Vector v = new Vector();

    //Add elements to Vector
    v.add("A");
    v.add("B");
    v.add("C");
    v.add("D");
    v.add("E");

    System.out.println("Before Reverse Order, Vector Contains : " + v);

    /*
      To reverse the order of all elements of Java Vector use,
      static void reverse(List list) method of Collections class.

      This method reverse the order of elements of specified list.
    */

    Collections.reverse(v);

    System.out.println("After Reverse Order, Vector Contains : " + v);
  }
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:26,代码来源:ReverseOrderVectorExample.java

示例4: stringSort

import java.util.Collections; //导入方法依赖的package包/类
@Test
public void stringSort() {

    List<TestPersonInterface> toSort = getTestData();

    toSort.sort(new ReflectiveSorter<>(TestPersonInterface.class, getOptions("lastName", "asc")));
    String[] expectedNames = {
        "Feynman",
        "Heisenberg",
        "Maxwell",
        "Schrödinger"
    };

    for (int i = 0; i < expectedNames.length; i++) {
        assertEquals(toSort.get(i).getLastName(), expectedNames[i]);
    }

    toSort.sort(new ReflectiveSorter<>(TestPersonInterface.class, getOptions("lastName", "DESC")));
    List<String> reversed = Arrays.asList(expectedNames);
    Collections.reverse(reversed);

    for (int i = 0; i < expectedNames.length; i++) {
        assertEquals(toSort.get(i).getLastName(), expectedNames[i]);
    }
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:26,代码来源:ReflectiveSorterTest.java

示例5: update

import java.util.Collections; //导入方法依赖的package包/类
public void update(Vector ns) {
      notes = ns;
      // NotesVectorSorter.sort(notes);
Collections.sort(notes);
if (sortOrderDesc) {
	Collections.reverse(notes);		    
}		
      updateUI();
  }
 
开发者ID:ser316asu,项目名称:Neukoelln_SER316,代码行数:10,代码来源:NotesList.java

示例6: checkRows

import java.util.Collections; //导入方法依赖的package包/类
private List<ExpandedPair> checkRows(boolean reverse) {
  // Limit number of rows we are checking
  // We use recursive algorithm with pure complexity and don't want it to take forever
  // Stacked barcode can have up to 11 rows, so 25 seems reasonable enough
  if (this.rows.size() > 25) {
    this.rows.clear();  // We will never have a chance to get result, so clear it
    return null;
  }

  this.pairs.clear();
  if (reverse) {
    Collections.reverse(this.rows);
  }

  List<ExpandedPair> ps = null;
  try {
    ps = checkRows(new ArrayList<ExpandedRow>(), 0);
  } catch (NotFoundException e) {
    // OK
  }

  if (reverse) {
    Collections.reverse(this.rows);
  }

  return ps;
}
 
开发者ID:simplezhli,项目名称:Tesseract-OCR-Scanner,代码行数:28,代码来源:RSSExpandedReader.java

示例7: calculateNextPermutation

import java.util.Collections; //导入方法依赖的package包/类
void calculateNextPermutation() {
  int j = findNextJ();
  if (j == -1) {
    nextPermutation = null;
    return;
  }

  int l = findNextL(j);
  Collections.swap(nextPermutation, j, l);
  int n = nextPermutation.size();
  Collections.reverse(nextPermutation.subList(j + 1, n));
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:13,代码来源:Collections2.java

示例8: RatingCalculatorTeam

import java.util.Collections; //导入方法依赖的package包/类
public RatingCalculatorTeam(List<Team> allContestants) {
    this.allContestants = (ArrayList<Team>) allContestants;
    this.numberOfContestants = allContestants.size();
    recalculateRanks();
    Collections.sort(this.allContestants);
    Collections.reverse(allContestants);
}
 
开发者ID:WslF,项目名称:CF-rating-prediction,代码行数:8,代码来源:RatingCalculatorTeam.java

示例9: viterbi

import java.util.Collections; //导入方法依赖的package包/类
public void viterbi(String sentence, List<String> tokens) {
    Vector<Map<Character, Double>> v = new Vector<Map<Character, Double>>();
    Map<Character, Node> path = new HashMap<Character, Node>();

    v.add(new HashMap<Character, Double>());
    for (char state : states) {
        Double emP = emit.get(state).get(sentence.charAt(0));
        if (null == emP)
            emP = MIN_FLOAT;
        v.get(0).put(state, start.get(state) + emP);
        path.put(state, new Node(state, null));
    }

    for (int i = 1; i < sentence.length(); ++i) {
        Map<Character, Double> vv = new HashMap<Character, Double>();
        v.add(vv);
        Map<Character, Node> newPath = new HashMap<Character, Node>();
        for (char y : states) {
            Double emp = emit.get(y).get(sentence.charAt(i));
            if (emp == null)
                emp = MIN_FLOAT;
            Pair<Character> candidate = null;
            for (char y0 : prevStatus.get(y)) {
                Double tranp = trans.get(y0).get(y);
                if (null == tranp)
                    tranp = MIN_FLOAT;
                tranp += (emp + v.get(i - 1).get(y0));
                if (null == candidate)
                    candidate = new Pair<Character>(y0, tranp);
                else if (candidate.freq <= tranp) {
                    candidate.freq = tranp;
                    candidate.key = y0;
                }
            }
            vv.put(y, candidate.freq);
            newPath.put(y, new Node(y, path.get(candidate.key)));
        }
        path = newPath;
    }
    double probE = v.get(sentence.length() - 1).get('E');
    double probS = v.get(sentence.length() - 1).get('S');
    Vector<Character> posList = new Vector<Character>(sentence.length());
    Node win;
    if (probE < probS)
        win = path.get('S');
    else
        win = path.get('E');

    while (win != null) {
        posList.add(win.value);
        win = win.parent;
    }
    Collections.reverse(posList);

    int begin = 0, next = 0;
    for (int i = 0; i < sentence.length(); ++i) {
        char pos = posList.get(i);
        if (pos == 'B')
            begin = i;
        else if (pos == 'E') {
            tokens.add(sentence.substring(begin, i + 1));
            next = i + 1;
        }
        else if (pos == 'S') {
            tokens.add(sentence.substring(i, i + 1));
            next = i + 1;
        }
    }
    if (next < sentence.length())
        tokens.add(sentence.substring(next));
}
 
开发者ID:zoyanhui,项目名称:jieba4j-tag,代码行数:72,代码来源:FinalSeg.java

示例10: injectScripts

import java.util.Collections; //导入方法依赖的package包/类
public void injectScripts(ScriptUrl[] scripts, SynchronousScriptsCallback callback) {
    Stack<ScriptUrl> scriptsStack = new Stack<>();
    Collections.addAll(scriptsStack, scripts);
    Collections.reverse(scriptsStack);

    RequestCallback nextScriptLoaderCallback = createNextScriptLoaderCallback(scriptsStack, callback);

    injectScript(scriptsStack, nextScriptLoaderCallback);
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:10,代码来源:SynchronousScriptsLoader.java

示例11: getList

import java.util.Collections; //导入方法依赖的package包/类
private List<Element> getList() {
	List<Element> result = new ArrayList<Element>();
	for (PathNode n = this; n != null; n = n.prev)
		result.add(n.element);
	Collections.reverse(result);
	return result;
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:8,代码来源:PathLibrary.java

示例12: sorted

import java.util.Collections; //导入方法依赖的package包/类
public static <T extends Comparable<T>, V> List<V> sorted(Map<T,V> c, boolean reverse) {
    List<T> t = new ArrayList<T>(c.keySet());
    Collections.sort(t);
    if ( reverse ) Collections.reverse(t);

    List<V> l = new ArrayList<V>();
    for ( T k : t ) {
        l.add(c.get(k));
    }
    return l;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:12,代码来源:Utils.java

示例13: reorder

import java.util.Collections; //导入方法依赖的package包/类
@Override
protected void reorder(List<Item> items) {
    Collections.reverse(items);
}
 
开发者ID:PrivacyStreams,项目名称:PrivacyStreams,代码行数:5,代码来源:StreamReverser.java

示例14: closeRadialMenuAnimation

import java.util.Collections; //导入方法依赖的package包/类
private AnimatorSet closeRadialMenuAnimation(Point center) {
    setAnimating(true);
    Animator lastAnimation = null;
    int startAngle = floatingMenuButton.getStartAngle();
    int endAngle = floatingMenuButton.getEndAngle();
    int radius = floatingMenuButton.getRadius();
    List<SubButton> subActionItems = menu.getSubMenuButtons();
    ArrayList<Animator> animatorArrayList = new ArrayList<>();
    for (int i = 0; i < subActionItems.size(); i++) {
        final SubButton currentSubButton = subActionItems.get(i);
        final View currentSubButtonView = currentSubButton.getView();
        // Button Properties along the animation
        ArrayList<PropertyValuesHolder> properties = new ArrayList<>();
        properties.add(PropertyValuesHolder.ofFloat(View.SCALE_X, (float) 0.75));
        properties.add(PropertyValuesHolder.ofFloat(View.SCALE_Y, (float) 0.75));
        PropertyValuesHolder[] parameters = new PropertyValuesHolder[properties.size() - 1];
        parameters = properties.toArray(parameters);
        ObjectAnimator propertiesAnimation = ObjectAnimator.ofPropertyValuesHolder(currentSubButtonView, parameters);
        // Button Position along the animation
        final ArrayList<Point> radialPointsPorCurrentPosition = getArcPointsForButton(center, startAngle, endAngle, subActionItems.size(), i, radius);
        Collections.reverse(radialPointsPorCurrentPosition);
        ValueAnimator positionAnimation = ValueAnimator.ofFloat(0, radialPointsPorCurrentPosition.size());
        positionAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                Float value = ((Float) animation.getAnimatedValue());
                if (value.intValue() < radialPointsPorCurrentPosition.size()) {
                    Point p = radialPointsPorCurrentPosition.get(value.intValue());
                    currentSubButtonView.setX(p.x);
                    currentSubButtonView.setY(p.y);
                    currentSubButton.setX(p.x);
                    currentSubButton.setY(p.y);
                }
            }
        });
        positionAnimation.setDuration(closingDuration);
        positionAnimation.setInterpolator(closingInterpolator);
        menuButtonAnimationListener = new FloatingMenuButtonAnimationListener(FloatingMenuAnimationHandler.this, currentSubButton, MenuState.CLOSING_RADIAL);
        positionAnimation.addListener(menuButtonAnimationListener);
        if (i == 0) {
            lastAnimation = positionAnimation;
        }
        animatorArrayList.add(propertiesAnimation);
        animatorArrayList.add(positionAnimation);
    }
    if (lastAnimation != null) {
        lastAnimation.addListener(this);
    }
    AnimatorSet closeRadialAnimatorSet = new AnimatorSet();
    closeRadialAnimatorSet.playTogether(animatorArrayList);
    return closeRadialAnimatorSet;
}
 
开发者ID:rjsvieira,项目名称:floatingMenu,代码行数:53,代码来源:FloatingMenuAnimationHandler.java

示例15: getClassDataLayout0

import java.util.Collections; //导入方法依赖的package包/类
private ClassDataSlot[] getClassDataLayout0()
    throws InvalidClassException
{
    ArrayList<ClassDataSlot> slots = new ArrayList<>();
    Class<?> start = cl, end = cl;

    // locate closest non-serializable superclass
    while (end != null && Serializable.class.isAssignableFrom(end)) {
        end = end.getSuperclass();
    }

    HashSet<String> oscNames = new HashSet<>(3);

    for (ObjectStreamClass d = this; d != null; d = d.superDesc) {
        if (oscNames.contains(d.name)) {
            throw new InvalidClassException("Circular reference.");
        } else {
            oscNames.add(d.name);
        }

        // search up inheritance hierarchy for class with matching name
        String searchName = (d.cl != null) ? d.cl.getName() : d.name;
        Class<?> match = null;
        for (Class<?> c = start; c != end; c = c.getSuperclass()) {
            if (searchName.equals(c.getName())) {
                match = c;
                break;
            }
        }

        // add "no data" slot for each unmatched class below match
        if (match != null) {
            for (Class<?> c = start; c != match; c = c.getSuperclass()) {
                slots.add(new ClassDataSlot(
                    ObjectStreamClass.lookup(c, true), false));
            }
            start = match.getSuperclass();
        }

        // record descriptor/class pairing
        slots.add(new ClassDataSlot(d.getVariantFor(match), true));
    }

    // add "no data" slot for any leftover unmatched classes
    for (Class<?> c = start; c != end; c = c.getSuperclass()) {
        slots.add(new ClassDataSlot(
            ObjectStreamClass.lookup(c, true), false));
    }

    // order slots from superclass -> subclass
    Collections.reverse(slots);
    return slots.toArray(new ClassDataSlot[slots.size()]);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:54,代码来源:ObjectStreamClass.java


注:本文中的java.util.Collections.reverse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。