示例#1
0
文件: HashTable.cs 项目: kepon2/cP
        // добавление элемента
        public void Add(info record)
        {
            Node node = new Node(record.field1, record.field2, record.field3);

            node.Next = head;
            head      = node;
            if (count == 0)
            {
                tail = head;
            }
            count++;
        }
示例#2
0
文件: HashTable.cs 项目: kepon2/cP
        //-1 - dont find
        public int findInArray(info record)
        {
            int i = 0;

            foreach (info rec in array)
            {
                if (i == arraySize - 1)
                {
                    i = -1;
                    break;
                }
                if (rec == record)
                {
                    break;
                }
                i++;
            }
            return(i);
        }
示例#3
0
文件: HashTable.cs 项目: kepon2/cP
        public string pushBackArray(string field1, string field2, string field3)
        {
            info record = new info(field1, field2, field3);

            if (arraySize == 1)
            {
                array[arraySize - 1] = record;
                arraySize++;
                Array.Resize(ref array, arraySize);
                return("Запись успешно добавлена");
            }
            else
            {
                array[arraySize - 1] = record;
                arraySize++;
                Array.Resize(ref array, arraySize);
                return("Запись успешно добавлена");
            }
        }
示例#4
0
文件: HashTable.cs 项目: kepon2/cP
        public string eraseFromArray(string field2, string field1, string field3)
        {
            info record = new info(field2, field1, field3);

            if (arraySize == 0)
            {
                return("Удаление невозможно справочник пуст");
            }
            else
            {
                int refRecordToRemove = this.findInArray(record);
                if (refRecordToRemove != -1)
                {
                    this.swapRecords(ref this.array, refRecordToRemove);
                    arraySize--;
                    Array.Resize(ref this.array, arraySize);
                    return("Запись успешно удалена");
                }
                else
                {
                    return("Удаление невозможно запись не содержится в справочнике");
                }
            }
        }
示例#5
0
文件: HashTable.cs 项目: kepon2/cP
        public void addHashTable(info record)
        {
            int hashAdress = hFunction(record.field1);

            this.arrayRoot[hashAdress].Add(record);
        }
示例#6
0
文件: Form1.cs 项目: kepon2/cP
        //Загрузка спавочников
        private void initPersonnelInfo_Click(object sender, EventArgs e)
        {
            this.listBonusInfo.Rows.Clear();
            this.listPayInfo.Rows.Clear();
            this.listPersonnelInfo.Rows.Clear();
            this.listEmployeeInfo.Rows.Clear();
            if (bynaryTreeSourceData.arraySize != 1 && bynaryTreeSourceData.array[0].field1 != null)
            {
                bynaryTreeSourceData.root      = null;
                bynaryTreeSourceData.arraySize = 1;
                Array.Resize(ref bynaryTreeSourceData.array, bynaryTreeSourceData.arraySize);
                bynaryTreeSourceData.array[0].field1 = null;
                bynaryTreeSourceData.array[0].field2 = null;
                bynaryTreeSourceData.array[0].field3 = null;

                payInfoMap.arraySize = 1;
                Array.Resize(ref payInfoMap.array, payInfoMap.arraySize);
                payInfoMap.array[0].field1 = null;
                payInfoMap.array[0].field2 = null;
                payInfoMap.array[0].field3 = null;
                Array.Resize(ref payInfoMap.arrayForReport, 0);
                payInfoMap.arrayForReportSize = 16;
                Array.Resize(ref payInfoMap.arrayForReport, payInfoMap.arrayForReportSize);

                personnelMap.arraySize = 1;
                Array.Resize(ref personnelMap.array, personnelMap.arraySize);
                personnelMap.array[0].field1 = null;
                personnelMap.array[0].field2 = null;
                personnelMap.array[0].field3 = null;
                Array.Resize(ref personnelMap.arrayRoot, 0);
                personnelMap.arrayRootSize = 16;
                Array.Resize(ref personnelMap.arrayRoot, personnelMap.arrayRootSize);
                for (int i = 0; i < personnelMap.arrayRootSize - 1; i++)
                {
                    personnelMap.arrayRoot[i] = new LinkedList();
                }

                employeeMap.arraySize = 1;
                Array.Resize(ref employeeMap.array, employeeMap.arraySize);
                employeeMap.array[0].field1 = null;
                employeeMap.array[0].field2 = null;
                employeeMap.array[0].field3 = null;
                Array.Resize(ref employeeMap.arrayRoot, 0);
                employeeMap.arrayRootSize = 16;
                Array.Resize(ref employeeMap.arrayRoot, employeeMap.arrayRootSize);
                for (int i = 0; i < employeeMap.arrayRootSize - 1; i++)
                {
                    employeeMap.arrayRoot[i] = new LinkedList();
                }
            }

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                objRW.openReader(openFileDialog.FileName);
                sourceFileName = openFileDialog.FileName;
            }
            else
            {
                return;
            }
            string tmpStringFromFile = objRW.reader.ReadLine();

            string[] parsedStringForHashTable = new string[3];

            while (tmpStringFromFile != null && tmpStringFromFile[0] == '1')
            {
                parsedStringForHashTable    = objRW.readerPars(tmpStringFromFile, 1);
                parsedStringForHashTable[1] = parsedStringForHashTable[1].Remove(0, 2);
                parsedStringForHashTable[0] = payInfoMap.getEmptyHashAddress(parsedStringForHashTable[1]).ToString();
                this.listBonusInfo.Rows.Add(parsedStringForHashTable);
                payInfoMap.pushBackArray(parsedStringForHashTable[1], parsedStringForHashTable[2], parsedStringForHashTable[3]);
                pMap.info record = new pMap.info(parsedStringForHashTable[2], parsedStringForHashTable[1], parsedStringForHashTable[3]);
                payInfoMap.addInArrayForReport(record);
                tmpStringFromFile = objRW.reader.ReadLine();
            }

            string[] parsedString = new string[2];
            while (tmpStringFromFile[0] == '2')
            {
                parsedString    = objRW.readerPars(tmpStringFromFile);
                parsedString[0] = parsedString[0].Remove(0, 2);
                this.listPayInfo.Rows.Add(parsedString);
                bynaryTreeSourceData.pushBackArray(parsedString[0], parsedString[1], parsedString[2]);
                tmpStringFromFile = objRW.reader.ReadLine();
            }
            bynaryTreeSourceData.initTreeFromePayArray(ref bynaryTreeSourceData.array);

            parsedString = null;

            while (tmpStringFromFile[0] == '3')
            {
                parsedStringForHashTable    = objRW.readerPars(tmpStringFromFile, 1);
                parsedStringForHashTable[1] = parsedStringForHashTable[1].Remove(0, 2);
                parsedStringForHashTable[0] = personnelMap.getHash(parsedStringForHashTable[1]).ToString();
                HashTable.info record = new HashTable.info(parsedStringForHashTable[0], parsedStringForHashTable[1], parsedStringForHashTable[2]);
                this.listPersonnelInfo.Rows.Add(parsedStringForHashTable);
                personnelMap.pushBackArray(parsedStringForHashTable[1], parsedStringForHashTable[2], parsedStringForHashTable[3]);
                tmpStringFromFile = objRW.reader.ReadLine();
            }
            personnelMap.initHashTableFromArray();

            while (tmpStringFromFile != null)
            {
                parsedStringForHashTable    = objRW.readerPars(tmpStringFromFile, 1);
                parsedStringForHashTable[1] = parsedStringForHashTable[1].Remove(0, 2);
                parsedStringForHashTable[0] = employeeMap.getHash(parsedStringForHashTable[1]).ToString();
                HashTable.info record = new HashTable.info(parsedStringForHashTable[0], parsedStringForHashTable[1], parsedStringForHashTable[2]);
                this.listEmployeeInfo.Rows.Add(parsedStringForHashTable);
                employeeMap.pushBackArray(parsedStringForHashTable[1], parsedStringForHashTable[2], parsedStringForHashTable[3]);
                tmpStringFromFile = objRW.reader.ReadLine();
            }
            employeeMap.initHashTableFromArray();

            objRW.closeReader();
        }