// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   WishList.java

import java.io.File;
import java.util.ArrayList;
import java.util.Random;

public class WishList
{

    public FileCRCCounter GetQuestion(int index)
    {
        if(vList.size() > index)
            return (FileCRCCounter)vList.get(index);
        else
            return null;
    }

    public WishList()
    {
        vList = new ArrayList();
    }

    public void PrepareRandomList(int iElems, int iSeed, String sCurrentLevel)
    {
        vList.clear();
        File cIdxFile = new File(WishListCounter.s_sWishListIdxFile);
        int iLastAvailID = (int)(cIdxFile.length() / 4L);
        Random cRandom = new Random(iSeed);
        WishListCounter cWishListCounter = new WishListCounter(sCurrentLevel);
        for(int i = 0; i < iElems; i++)
        {
            int iID = 0;
            if(i > 0)
                iID = cRandom.nextInt(iLastAvailID + 1);
            String sFileName = cWishListCounter.WishListFileIDToPath(iID);
            if(sFileName != null)
            {
                File cFile = new File(sFileName);
                int len = (int)cFile.length();
                int iStart = 0;
                int iEnd = -1;
                if(i > 0)
                {
                    iStart = cRandom.nextInt(len);
                    int iToEnd = len - iStart;
                    if(iToEnd > 2048)
                        iEnd = iStart + cRandom.nextInt(2048);
                    else
                        iEnd = iStart + cRandom.nextInt(iToEnd);
                }
                FileCRCCounter cQuestion = new FileCRCCounter();
                cQuestion.Set(cWishListCounter.WishListFileIDToPath(iID), iStart, iEnd);
                cQuestion.SetFileID(iID);
                vList.add(cQuestion);
            }
        }

    }

    public int GetQuestionCount()
    {
        int iQuestionCount = 0;
        int iMaxIdx = GetQuestionMaxIdx();
        for(int i = 0; i < iMaxIdx; i++)
            if(vList.get(i) != null)
                iQuestionCount++;

        return iQuestionCount;
    }

    public int GetQuestionMaxIdx()
    {
        return vList.size();
    }

    ArrayList vList;
}
