コード例 #1
0
        public static CoordIndexer FromIndex(ISizeObject sizeObject, int index)
        {
            int dimensions = sizeObject.Dimensions, size = 1, value = 0, i;
            var coords = new int[dimensions];

            for (i = 0; i < dimensions; i++)
            {
                size *= sizeObject.GetSize(i);
            }
            for (i = dimensions - 1; i >= 0; i--)
            {
                size     /= sizeObject.GetSize(i);
                coords[i] = index % size - value;
                value    += coords[i];
            }
            return(new CoordIndexer(sizeObject, coords));
        }
コード例 #2
0
 public CoordIndexer(ISizeObject sizeObject, params int[] coord)
 {
     if (sizeObject == null)
     {
         throw new ArgumentNullException("sizeObject");
     }
     if (coord == null)
     {
         throw new ArgumentNullException("coord");
     }
     this.dimensions = sizeObject.Dimensions;
     if (dimensions < 1)
     {
         throw new ArgumentOutOfRangeException("sizeObject", "dimensions of a size object must be greater or equals to 1.");
     }
     this.sizeObject = sizeObject;
     this.coord      = new int[dimensions];
     Array.Copy(coord, this.coord, Math.Min(dimensions, coord.Length));
 }
コード例 #3
0
 public bool IsChild(ISizeObject parent)
 {
     return(parent == sizeObject);
 }