Skip to content

Instantly share code, notes, and snippets.

@blazsolar
Last active January 3, 2016 16:49
Show Gist options
  • Save blazsolar/8491810 to your computer and use it in GitHub Desktop.
Save blazsolar/8491810 to your computer and use it in GitHub Desktop.
3. naloga
public class PodatkiOPotnikih<E extends Potnik> {
private HashMap<Integer, Clen> elements;
public PodatkiOPotnikih() {
elements = new HashMap<>();
}
public PodatkiOPotnikih(Collection<E> col) {
elements = new HashMap<>();
for(E e : col) {
add(e);
}
}
public void add(E e) {
int razred = e.getRazred();
Clen c = elements.get(razred);
if(c == null) {
elements.put(razred, new Clen(e));
} else {
c.add(e);
}
}
private class Clen<E> {
private E el;
private Clen<E> next;
publoc Clen(E el) {
this.el = el;
}
public void add(E element) {
if(next == null) {
next = new Clen(element);
} else {
el.add(element);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment