Ejemplo n.º 1
0
        public static bool Peek <T>(this ICapture <T> segment, out T value)
        {
            // growing parent segements is the responsibility of the parent segement
            if (!segment.CanGrow())
            {
                value = default;
                return(false);
            }

            // calculate the index of the parent where the peek element is located
            var index = segment.Count + segment.Offset;

            value = segment.Parent[index];
            return(true);
        }
Ejemplo n.º 2
0
        public static bool Grow <T>(this ICapture <T> segment)
        {
            // we can only grow child segments
            if (!segment.CanGrow())
            {
                return(false);
            }

            if (segment.IsReadOnly)
            {
                return(false);
            }

            segment.Count++;
            return(true);
        }