예제 #1
0
        public void Add(TileIndex id, bool exists)
        {
            ulong     cacheLine = 0;
            TileIndex parent    = id.GetLowerTile(levelDelta);

            cache.TryGetValue(parent, out cacheLine);

            int x = id.X - parent.X * levelSize;
            int y = id.Y - parent.Y * levelSize;

            int position = x * levelSize + y;

            if (exists)
            {
                cacheLine |= ((ulong)1) << position;
            }
            else
            {
                cacheLine &= ~(((ulong)1) << position);
            }

            cache[parent] = cacheLine;
        }
예제 #2
0
        public bool Contains(TileIndex id)
        {
            int level = (int)id.Level;

            if (level < minLevel || level > maxLevel)
            {
                return(false);
            }

            TileIndex parent = id.GetLowerTile(levelDelta);

            ulong cacheLine;

            if (cache.TryGetValue(parent, out cacheLine))
            {
                int x = id.X - parent.X * levelSize;
                int y = id.Y - parent.Y * levelSize;

                int position = x * levelSize + y;

                return((cacheLine & ((ulong)1 << position)) != 0);
            }
            return(false);
        }