Example #1
0
        //��ȡһ����ԭ�����и���ԭ��ֱ������λ��
        public List<int> getparents(string primitive)
        {
            List<int> list = new List<int>();
            //��ȡ�����ԭ��ID
            try
            {
                int id = PRIMITIVESID[primitive];
                //���������ԭ��ID
                if (id >= 0)
                {
                    list.Add(id);//������ԭ��ID--���仰˵��������������ԭID����
                    Primitive parent = ALLPRIMITIVES[id];//��ȡ��ԭ�ĸ�����ԭ
                    while (!parent.isTop())//�ж��Ƿ�Ϊ����Ľڵ�
                    {
                        list.Add(parent.getParentId());
                        parent = ALLPRIMITIVES[parent.getParentId()];

                    }
                }
            }
            catch (Exception ex)
            {
            }

            //�����𼶴�����Ľڵ��ID����Ҷ�ӽڵ㵽���ڵ㡣
            return list;
        }
Example #2
0
 //��ӹ�ϵ��ԭ
 //�����ϵ��ԭ��key��Ӧ��ListΪ�գ����½�һ��������value��
 //���򣬾�ֱ���ڹ�ϵ��ԭ��key��Ӧ��List����ֱ������value��
 public void addRelationalPrimitive(string key, string value)
 {
     List<string> list = null;
     if (relationalPrimitives.ContainsKey(key))
     {
         list = relationalPrimitives[key];
         list.Add(value);
     }
     else {
         list = new List<string>();
         list.Add(value);
         relationalPrimitives.Add(key, list);
     }
 }
 //����һ������
 public void addWord(Word word)
 {
     if (ALLWORDS.ContainsKey(word.getWord()))
     {
         List<Word> list = ALLWORDS[word.getWord()];
         list.Add(word);
     }
     else
     {
         List<Word> list = new List<Word>();
         list.Add(word);
         ALLWORDS.Add(word.getWord(), list);
     }
 }
Example #4
0
 public static List<Budjet> GetBudget()
 {
     List<Budjet> bdjs = new List<Budjet>();
     using (StreamReader reader = new StreamReader("Data.txt"))
     {
         string line = reader.ReadLine();
         do
         {
             string[] currentbdj = line.Split('|');
             bdjs.Add(new Budjet()
             {
                 Data = currentbdj[0],
                 Costs = currentbdj[1],
                 Prize = int.Parse(currentbdj[2]),
             });
             line = reader.ReadLine();
         } while (line != null);
     }
     return bdjs;
 }