Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package container;
- //import java.util.ArrayList;
- import java.util.Collection;
- import java.util.Iterator;
- import util.searchable.ISearchFilter;
- import util.searchable.ISearchableByFilter;
- public class Container<E> {
- public IContainerElement<E> head;
- //constructor
- public Container() {
- this.head=null;
- }
- public boolean add (E e) throws NullPointerException {
- if(e==null) {
- throw new NullPointerException("You cant enter null");
- }
- ContainerElement<E> node = new ContainerElement<E>(e);
- if(head==null) {
- head=node;
- }
- else {
- ContainerElement<E> n = (ContainerElement<E>) head;
- while(n.hasNextElement()) {
- n=(ContainerElement<E>) n.getNextElement();
- }
- n.next=node;
- }
- return true;
- }
- //probna funkcija
- public void show() {
- IContainerElement<E> node = head;
- while(node.hasNextElement()) {
- System.out.println(node.getData());
- node=node.getNextElement();
- }
- System.out.println(node.getData());
- }
- public boolean addAll(Collection<? extends E> c) {
- for(E e : c) {
- ContainerElement<E> node = new ContainerElement<E>(e);
- }
- return true;
- }
- public void clear() {
- ContainerElement<E> node = new ContainerElement<E>();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment