public TreeMap<Double,DatasetObject> retrieve(TreeMap<Integer,Double> identifiers, int k)
    {

        java.util.Iterator s=identifiers.entrySet().iterator();
        TreeMap res=null;
        if(dataset!=null)
        {
            res=new TreeMap();
            while(s.hasNext()&& k>0)
            {
                k--;
                java.util.Map.Entry<Integer,Double> e=(java.util.Map.Entry)s.next();
                Double dist = e.getValue();
                Integer o=e.getKey();
                DatasetObject object = dataset.getObject(o);
                object.setInternalId(o);   //Just to be sure. It should have already been done in objectDatabase.Insert()
                while(res.get(dist)!=null)
                {
                    dist+=0.00000001;
                }
                res.put(dist,object);
            }
        }
        else System.out.println("Retrieval not performed. No dataset associated!");
        return res;       
    }