source: josm/trunk/src/org/openstreetmap/josm/tools/CompositeList.java@ 8419

Last change on this file since 8419 was 8290, checked in by Don-vip, 9 years ago

code cleanup

  • Property svn:eol-style set to native
File size: 830 bytes
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.tools;
3
4import java.util.AbstractList;
5import java.util.List;
6
7/**
8 * Joined List build from two Lists (read-only).
9 *
10 * Extremely simple single-purpose implementation.
11 * @param <T>
12 * @since 7109
13 */
14public class CompositeList<T> extends AbstractList<T> {
15 private List<? extends T> a,b;
16
17 /**
18 * Constructs a new {@code CompositeList} from two lists.
19 * @param a First list
20 * @param b Second list
21 */
22 public CompositeList(List<? extends T> a, List<? extends T> b) {
23 this.a = a;
24 this.b = b;
25 }
26
27 @Override
28 public T get(int index) {
29 return index < a.size() ? a.get(index) : b.get(index - a.size());
30 }
31
32 @Override
33 public int size() {
34 return a.size() + b.size();
35 }
36}
Note: See TracBrowser for help on using the repository browser.