Java List Sub List sublist(LinkedHashSet base, int start, int count)

Here you can find the source of sublist(LinkedHashSet base, int start, int count)

Description

sublist

License

Mozilla Public License

Declaration

public static <T> List<T> sublist(LinkedHashSet<T> base, int start,
            int count) 

Method Source Code

//package com.java2s;
/*/*from  w ww. ja va2  s  . c  o  m*/
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 * Copyright (c) 2013, MPL CodeInside http://codeinside.ru
 */

import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;

public class Main {
    public static <T> List<T> sublist(LinkedHashSet<T> base, int start,
            int count) {
        Iterator<T> iterator = base.iterator();
        int index = 0;
        final List<T> result = new ArrayList<T>();
        while (iterator.hasNext() && index < (start + count)) {
            T next = iterator.next();
            if (index < start) {
                index++;
                continue;
            }
            index++;
            result.add(next);
        }
        return result;
    }
}

Related

  1. subList(final List oriList, int[] indexes)
  2. subList(final List list, final int first, final int count)
  3. subList(final List list, final int offset, final int amount)
  4. subList(final List list, final int startIndex, final int endIndex)
  5. subList(final List source, final int... indices)
  6. subList(List list, int start, int end)
  7. subList(List list, int fromIndex, int toIndex)
  8. subList(List list, int page, int size)
  9. subList(List list, int fromIndex)