Пример #1
0
        public object GetVal(string key)
        {
            int           i             = 0;
            PKeyCharValue aTempTreeList = aPKeyTreeHeadList;
            int           iTempIndex    = aTempTreeList.IndexOfArray(key[i]);

            while (iTempIndex != NOTFOUND)
            {
                i++;
                if (i >= key.Length)
                {
                    aTempTreeList = (PKeyCharValue)aTempTreeList.aPKeyTreeList[iTempIndex];
                    break;
                }
                aTempTreeList = (PKeyCharValue)aTempTreeList.aPKeyTreeList[iTempIndex];
                iTempIndex    = aTempTreeList.IndexOfArray(key[i]);
            }
            if (iTempIndex == NOTFOUND)
            {
                return(null);
            }
            else
            {
                return(aTempTreeList.sValue);
            }
        }
Пример #2
0
        public void SetVal(string key, object val)
        {
            int           i             = 0;
            PKeyCharValue aTempTreeList = aPKeyTreeHeadList;
            int           iTempIndex    = aTempTreeList.IndexOfArray(key[i]);

            while (iTempIndex != NOTFOUND)
            {
                i++;
                if (i >= key.Length)
                {
                    aTempTreeList = (PKeyCharValue)aTempTreeList.aPKeyTreeList[iTempIndex];
                    break;
                }
                aTempTreeList = (PKeyCharValue)aTempTreeList.aPKeyTreeList[iTempIndex];
                iTempIndex    = aTempTreeList.IndexOfArray(key[i]);
            }
            if (iTempIndex == NOTFOUND)
            {
                AddPrimaryKey(key, val);                //找不着就添加一个
            }
            else
            {
                aTempTreeList.sValue = val;
            }
        }
Пример #3
0
        public int AddCharElement(PKeyCharValue cPKeyCharValue)
        {
            int iIndex = NOTINSERT;

            for (int i = 0; i < aPKeyTreeList.Count; i++)
            {
                if (cPKeyCharValue.chKeyChar == ((PKeyCharValue)aPKeyTreeList[i]).chKeyChar)
                {
                    iIndex = i;
                    if (cPKeyCharValue.overwrite)
                    {
                        ((PKeyCharValue)aPKeyTreeList[i]).sValue = cPKeyCharValue.sValue;
                    }
                    break;
                }
                else if (cPKeyCharValue.chKeyChar < ((PKeyCharValue)aPKeyTreeList[i]).chKeyChar)
                {
                    aPKeyTreeList.Insert(i, cPKeyCharValue);
                    iIndex = i;
                    break;
                }
            }
            if (iIndex == NOTINSERT)           //没有被插入到树,那么就加进去
            {
                aPKeyTreeList.Add(cPKeyCharValue);
                iIndex = aPKeyTreeList.Count - 1;
            }
            return(iIndex);
        }
Пример #4
0
        //往关键字树中添加关键字
        public void AddPrimaryKey(string sPKeyName, object val)
        {
            PKeyCharValue cTempPKeyCharValue = aPKeyTreeHeadList;
            int           i = 0;
            int           iIndex;

            if (sPKeyName.Length == 0)
            {
                return;
            }
            for (; i < sPKeyName.Length - 1; i++)
            {
                iIndex             = cTempPKeyCharValue.AddCharElement(new PKeyCharValue(sPKeyName[i], null, false));
                cTempPKeyCharValue = (PKeyCharValue)cTempPKeyCharValue.aPKeyTreeList[iIndex];
            }
            cTempPKeyCharValue.AddCharElement(new PKeyCharValue(sPKeyName[i], val, true));
        }
Пример #5
0
 public ValClass()
 {
     aPKeyTreeHeadList = new PKeyCharValue('S', null, true);
 }