public boolean deleteKey(int key) {
        if (firstLink==lastLink) {
            firstLink=lastLink=null;
        return true;
        }
        if (firstLink.getDatum()==key) {
            firstLink.getNext().setPrevious(null);
            firstLink=firstLink.getNext();
            return true;
        }

        for (Link temp=firstLink.getNext();temp!=lastLink;temp = temp.getNext()) {
            if (temp.getDatum()==key) {
                temp.getNext().setPrevious(temp.getPrevious());
                temp.getPrevious().setNext(temp.getNext());
                return true;
            }
        }
        if (lastLink.getDatum()==key) {
            lastLink.getPrevious().setNext(null);
            lastLink = lastLink.getPrevious();
            return true;
        }
        return false;
    }