示例#1
0
        //插入一个关系记录
        public void insert(int countryid, int itemid, int score)
        {
            relation node = new relation();

            node.countryid = countryid;
            node.itemid    = itemid;
            node.score     = score;
            node.rank      = 1;

            if (head.next == null)
            {
                head.next = node;
            }
            else
            {
                relation current = head.next;
                while (current != null)
                {
                    if (current.itemid == node.itemid)
                    {
                        node.rank++;
                        if (node.score > current.score)
                        {
                            int tcid = current.countryid;
                            current.countryid = node.countryid;
                            node.countryid    = tcid;

                            int ts = current.score;
                            current.score = node.score;
                            node.score    = ts;
                        }
                    }
                    if (current.next == null)
                    {
                        current.next = node;
                        break;
                    }
                    current = current.next;
                }
            }
        }
示例#2
0
 public relation head; //头结点
 public RelationLink() //初始化头结点
 {
     head = new relation();
 }