示例#1
0
        internal void AddMember(Member member)
        {
            if (member.IsZero)
            {
                return;
            }

            int m = 0; int s = mems.Count;        // [m,s) の範囲を二分探索

            while (m < s)
            {
                int c   = (s + m) / 2;
                int cmp = Member.MemberOrder(member, mems[c]);
                if (cmp == 0)
                {
                    mems[c] += member;                   // 同じ因数集合を持つ項
                    return;
                }
                else if (cmp < 0)
                {
                    s = c;
                }
                else
                {
                    m = c + 1;
                }
            }

            // mems[m]<member<mems[s]
            mems.Insert(s, member);
            return;
        }