コード例 #1
0
ファイル: Group.cs プロジェクト: tksuoran/renderstack_net
        public Model IdTest(IDListEntry compareKey, out uint polygonId)
        {
            polygonId = 0;
            if (IdList.Count == 0 || compareKey.Key >= IdList.Last().Key)
            {
                return(null);
            }
            int index = IdList.BinarySearch(compareKey);

            if (index == ~IdList.Count)
            {
                /*  Index was after this IdList  */
                return(null);
            }
            else if (index < 0)
            {
                int larger = ~index;
                if (larger == 0)
                {
                    /*  Index was before this IdList  */
                    return(null);
                }
                Model model = IdList[larger - 1].Model;
                if (model != null)
                {
                    uint offset = IdList[larger - 1].Key;
                    polygonId = compareKey.Key - offset;
                    return(model);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                Model model = IdList[index].Model;
                if (model != null)
                {
                    uint offset = IdList[index].Key;
                    polygonId = compareKey.Key - offset;
                    return(model);
                }
                else
                {
                    return(null);
                }
            }
        }
コード例 #2
0
ファイル: Group.cs プロジェクト: tksuoran/renderstack_net
        public bool AlreadyHas(IDListEntry compareKey)
        {
            if (IdList.Count == 0 || compareKey.Key >= IdList.Last().Key)
            {
                return(false);
            }
            int index = IdList.BinarySearch(compareKey);

            if (index == ~IdList.Count)
            {
                return(false);
            }
            else if (index < 0)
            {
                int larger = ~index;
                if (larger == 0)
                {
                    /*  Index was before this IdList  */
                    return(false);
                }
            }
            return(true);
        }