public static BlockGraphItem <TimeSpan>[] BlockTime( BlockGraphItem <TimeSpan>[] blockstartGraphItems) { var startBlock = blockstartGraphItems[0].BlockNumber; var endBlock = blockstartGraphItems[blockstartGraphItems.Length - 1].BlockNumber; var totalBlocks = endBlock - startBlock; BlockGraphItem <TimeSpan>[] ret = new BlockGraphItem <TimeSpan> [totalBlocks]; TimeSpan lastBlockStartTime = blockstartGraphItems[0].Data; int lastBlockNumber = blockstartGraphItems[0].BlockNumber; int blockCounter = 0; for (int i = 1; i < blockstartGraphItems.Length; i++) { ref BlockGraphItem <TimeSpan> currentBlock = ref blockstartGraphItems[i]; var blocksTime = currentBlock.Data - lastBlockStartTime; var numberOfBlocks = currentBlock.BlockNumber - lastBlockNumber; var averageBlockTime = blocksTime / numberOfBlocks; for (int cnt = 0; cnt < numberOfBlocks; cnt++) { ret[blockCounter++] = new BlockGraphItem <TimeSpan>(lastBlockNumber + cnt, averageBlockTime); } lastBlockStartTime = currentBlock.Data; lastBlockNumber = currentBlock.BlockNumber; }
public bool Equals(BlockGraphItem <T> other) { return((this._blockNumber == other._blockNumber) && this._data.Equals(other._data)); }