Ejemplo n.º 1
0
    public void registerString(string key, string text, int dictionaryIndex)
    {
        int             fl, sl;
        RosettaHashDict dict;

        calculateHashCoordinates(key, out fl, out sl);


        dict = data [dictionaryIndex];
        ListRosettaDictElement1D targetList = dict.data.theList[fl].theList[sl];         // you can only register on the default translation


        bool found = false;
        int  i;

        for (i = 0; i < targetList.theList.Count; ++i)
        {
            if (targetList.theList [i].key.Equals(key))
            {
                found = true;
                break;
            }
        }


        if (found)           // update only text

        {
            targetList.theList [i].text = text;
        }
        else             // completely new entry

        {
            RosettaDictElement e = new RosettaDictElement();
            e.key  = key;
            e.text = text;
            targetList.theList.Add(e);
            //++nStrings;
        }
    }
Ejemplo n.º 2
0
    public string retrieveString(string key)
    {
        int fl, sl;

        RosettaHashDict currentTranslation;

        calculateHashCoordinates(key, out fl, out sl);

        currentTranslation = data[currentTranslationIndex];         //data[currentTranslationIndex];

        ListRosettaDictElement1D targetList = currentTranslation.data.theList[fl].theList[sl];

        string result = "";

        for (int i = 0; i < targetList.theList.Count; ++i)
        {
            if (targetList.theList [i].key.Equals(key))
            {
                result = targetList.theList [i].text;
                break;
            }
        }
        if (result.Equals(""))           // return default text
        {
            targetList = currentTranslation.data.theList[fl].theList[sl];
            for (int i = 0; i < targetList.theList.Count; ++i)
            {
                if (targetList.theList [i].key.Equals(key))
                {
                    result = targetList.theList [i].text;
                    break;
                }
            }
        }

        return(result);
    }
Ejemplo n.º 3
0
    public void initialize(int fls, int sls)
    {
        firstLevelHashSize  = fls;
        secondLevelHashSize = sls;
        ListRosettaDictElement2D new2DList;
        ListRosettaDictElement1D new1DList;

        data = new ListRosettaDictElement3D();


        for (int i = 0; i < fls; ++i)
        {
            new2DList = new ListRosettaDictElement2D();

            for (int j = 0; j < sls; ++j)
            {
                new1DList = new ListRosettaDictElement1D();

                new2DList.theList.Add(new1DList);
            }

            data.theList.Add(new2DList);
        }
    }