/// <inheritdoc/> public IArea CreateArea(long size) { if (size > Int32.MaxValue) { throw new IOException("'size' is too large."); } lock (this) { // Generate a unique id for this area. long id = uniqueIdKey; ++uniqueIdKey; // Create the element. var element = new InMemoryBlock(id, (int)size); // The position in the hash map int hashPos = (int)(id % areaMap.Length); // Add to the chain element.Next = areaMap[hashPos]; areaMap[hashPos] = element; return(element.GetArea(false)); } }
/// <inheritdoc/> public IArea CreateArea(long size) { if (size > Int32.MaxValue) throw new IOException("'size' is too large."); lock (this) { // Generate a unique id for this area. long id = uniqueIdKey; ++uniqueIdKey; // Create the element. var element = new InMemoryBlock(id, (int)size); // The position in the hash map int hashPos = (int)(id % areaMap.Length); // Add to the chain element.Next = areaMap[hashPos]; areaMap[hashPos] = element; return element.GetArea(false); } }