Java List Trim trimSequence(int m, List sequence)

Here you can find the source of trimSequence(int m, List sequence)

Description

trim Sequence

License

Open Source License

Declaration

public static List<String> trimSequence(int m, List<String> sequence) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.*;
import java.util.List;

public class Main {
    public static List<String> trimSequence(int m, List<String> sequence) {
        List<String> result = new ArrayList<String>();
        for (int i = sequence.size() - 1; result.size() < m; i--) {
            result.add(0, sequence.get(i));

        }//from w  w  w . j  a va2  s.c  o m
        assert result.size() == m;
        assert result.get(result.size() - 1).equals(sequence.get(sequence.size() - 1));
        return result;
    }
}

Related

  1. trimKeyFormat(String s3KeyFormat, List disallowedKeys)
  2. trimLeadingWhitespaces(List lines)
  3. trimList(List list)
  4. trimList(List source)
  5. trimListValues(List original)
  6. trimStringLineList(List lines)
  7. trimStrings(List list)
  8. trimStringToNewList(List list, Boolean isLower)
  9. trimSuffix(List strs)