public void PopulateHeapItems(byte[] buffer, ushort ibHnpm)
        {
            m_pageMap = new HeapOnNodePageMap(buffer, ibHnpm);

            int itemCount = m_pageMap.ItemCount;

            for (int itemIndex = 0; itemIndex < itemCount; itemIndex++)
            {
                int    itemOffset = m_pageMap.GetHeapItemStartOffset(itemIndex);
                int    itemSize   = m_pageMap.GetHeapItemSize(itemIndex);
                byte[] itemBytes  = new byte[itemSize];
                Array.Copy(buffer, itemOffset, itemBytes, 0, itemSize);
                HeapItems.Add(itemBytes);
            }
        }
        public byte[] GetBytes()
        {
            int headerLength = this.HeaderLength;
            int dataLength   = this.DataLength;
            // http://social.msdn.microsoft.com/Forums/en-US/os_binaryfile/thread/a5f9c653-40f5-4638-85d3-00c54607d984/
            // Padding to align to 2 byte boundary must be appended
            int paddingLength = (int)Math.Ceiling((double)(headerLength + dataLength) / 2) * 2 - (headerLength + dataLength);

            int firstItemOffset = headerLength;

            this.ibHnpm = (ushort)(headerLength + dataLength + paddingLength);
            int length = headerLength + dataLength + paddingLength + HeapOnNodePageMap.CalculateRecordLength(this.HeapItems.Count);

            byte[] buffer = new byte[length];
            WriteHeader(buffer, 0);
            WriteHeapItems(buffer, firstItemOffset);
            HeapOnNodePageMap.WriteBytes(buffer, ibHnpm, firstItemOffset, HeapItems);
            return(buffer);
        }