public InvertedFileIterator(int entryPar,String indexDirectory,int lexiconSizePar, InvertedFile invFile){
        synchronized(this){
            entry=entryPar;
            lexiconSize=lexiconSizePar;
            try{
                File pl_f=new File(indexDirectory+"/invfile/pl_e"+entry+"_sorted.dat");
                if(pl_f.exists())
                {
                    if(postingListFile==null){
//                        System.out.println("Opening posting list "+entry);
                        postingListFile=new RandomAccessFile(pl_f,"r");
                    }
                    if(postingListIndex==null){
//                        System.out.println("Reading index of posting list "+entry);
                        postingListIndex=new int[lexiconSize]; //positions range from 0 up to (including) the number of reference objects 
                        //Can we do the following by using MemoryMappedBuffers rather than random access files?
                        postingListFile.seek(0);
                        for(int s=0;s<postingListIndex.length;s++){
                            byte[] position_buff=new byte[4];
                            postingListFile.read(position_buff);
                            int position=it.cnr.isti.SimilaritySearch.MI_File.Conversions.byteArrayToInt(position_buff);
                            postingListIndex[s]=position;
                        }
                    }                    
    //            System.out.println(fromScoreParam+" "+toScoreParam+" "+fromPos+" "+toPos);
    //                pl=invFile[entry].getChannel().map(java.nio.channels.FileChannel.MapMode.READ_ONLY,fromPos,toPos-fromPos);
                    if(postingListMemoryMapped==null){
                        postingListMemoryMapped=postingListFile.getChannel().map(java.nio.channels.FileChannel.MapMode.READ_ONLY,postingListIndex[0],postingListFile.length()-postingListIndex[0]);
                    }
                }
                else{
                    currentPos=fromPos=toPos=0;
                }
            }catch(Exception e){
                System.err.println("Cannot open posting list");
                e.printStackTrace();    
            }
        }
    }