Ejemplo n.º 1
0
        private void GetRegionAtLocalOffset_(
            int localOffset,
            out IShardedList <T> region,
            out int regionOffset,
            out int regionIndex)
        {
            Asserts.Assert(localOffset >= 0, "Tried to access a negative offset!");
            Asserts.Assert(localOffset < this.Length,
                           "Tried to access beyond the end of the region!");

            var currentRegionOffset = 0;

            for (var i = 0; i < this.regions_.Count; ++i)
            {
                var currentRegion    = this.regions_[i];
                var nextRegionOffset = currentRegionOffset + currentRegion.Length;
                if (localOffset >= currentRegionOffset &&
                    localOffset < nextRegionOffset)
                {
                    region       = currentRegion;
                    regionOffset = currentRegionOffset;
                    regionIndex  = i;
                    return;
                }
                currentRegionOffset = nextRegionOffset;
            }

            region       = this;
            regionOffset = -1;
            regionIndex  = -1;
            Asserts.Fail("Failed to find a matching region, this should not happen.");
        }
Ejemplo n.º 2
0
        private int LocateRegion_(IShardedList <T> region)
        {
            var index = this.regions_.IndexOf(region);

            if (index >= 0)
            {
                return(index);
            }
            throw new NotSupportedException("Failed to find the region!");
        }
Ejemplo n.º 3
0
 private ShardedMemory(IShardedList <byte> impl)
 {
     this.impl_ = impl;
 }