public void purge()
    {
    	//removes DEAD contacts from the bucket
        for (Iterator<Contact> it = contacts.values().iterator(); it.hasNext();)
        {
            Contact node = it.next();
            if(!node.isAlive() && !isLocalNode(node))
                it.remove();
        }
        
        //replaces empty entries in the bucket with cache entries
        if(!isBucketFull() && !cache.isEmpty())
        {
            // The cache Map is in LRS order. Add the Contacts to a List and 
            // iterate it backwards so that we get the elements in MRS order.
            List<Contact> cont = new ArrayList<Contact>(getAllCachedContacts());
            for(int i = cont.size()-1; i>=0 && !isBucketFull(); i--)
            {
                Contact node = cont.get(i);
                
                if(node.isAlive())
                	contacts.put(node.getNodeId(), node);
                
                cache.remove(node.getNodeId());
            }
        }
    }