Last active
January 3, 2016 16:49
-
-
Save blazsolar/8491810 to your computer and use it in GitHub Desktop.
3. naloga
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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