public void testDecodeUInt64() { Assert.AreEqual(0L, NB.DecodeUInt64(b(0, 0, 0, 0, 0, 0, 0, 0), 0)); Assert.AreEqual(0L, NB.DecodeUInt64(Padb(3, 0, 0, 0, 0, 0, 0, 0, 0), 3)); Assert.AreEqual(3L, NB.DecodeUInt64(b(0, 0, 0, 0, 0, 0, 0, 3), 0)); Assert.AreEqual(3L, NB.DecodeUInt64(Padb(3, 0, 0, 0, 0, 0, 0, 0, 3), 3)); Assert.AreEqual(0xdeadbeefL, NB.DecodeUInt64(b(0, 0, 0, 0, 0xde, 0xad, 0xbe, 0xef), 0)); Assert.AreEqual(0xdeadbeefL, NB.DecodeUInt64(Padb(3, 0, 0, 0, 0, 0xde, 0xad, 0xbe, 0xef), 3)); Assert.AreEqual(0x0310adefL, NB.DecodeUInt64(b(0, 0, 0, 0, 0x03, 0x10, 0xad, 0xef), 0)); Assert.AreEqual(0x0310adefL, NB.DecodeUInt64(Padb(3, 0, 0, 0, 0, 0x03, 0x10, 0xad, 0xef), 3)); unchecked { Assert.AreEqual((long)0xc0ffee78deadbeefL, NB.DecodeUInt64(b(0xc0, 0xff, 0xee, 0x78, 0xde, 0xad, 0xbe, 0xef), 0)); Assert.AreEqual((long)0xc0ffee78deadbeefL, NB.DecodeUInt64(Padb(3, 0xc0, 0xff, 0xee, 0x78, 0xde, 0xad, 0xbe, 0xef), 3)); Assert.AreEqual(0x00000000ffffffffL, NB.DecodeUInt64(b(0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff), 0)); Assert.AreEqual(0x00000000ffffffffL, NB.DecodeUInt64(Padb(3, 0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff), 3)); Assert.AreEqual((long)0xffffffffffffffffL, NB.DecodeUInt64(b(0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff), 0)); Assert.AreEqual((long)0xffffffffffffffffL, NB.DecodeUInt64(Padb(3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff), 3)); } }
// p * 5 internal override long FindOffset(AnyObjectId objId) { int levelOne = objId.FirstByte; int levelTwo = BinarySearchLevelTwo(objId, levelOne); if (levelTwo == -1) { return(-1); } long p = NB.DecodeUInt32(offset32[levelOne], levelTwo << 2); if ((p & IS_O64) != 0) { return(NB.DecodeUInt64(offset64, (8 * (int)(p & ~IS_O64)))); } return(p); }
public override PackIndex.MutableEntry Next() { for (; this.levelOne < this._enclosing.names.Length; this.levelOne++) { if (this.levelTwo < this._enclosing.names[this.levelOne].Length) { int idx = this.levelTwo / (Constants.OBJECT_ID_LENGTH / 4) * 4; long offset = NB.DecodeUInt32(this._enclosing.offset32[this.levelOne], idx); if ((offset & PackIndexV2.IS_O64) != 0) { idx = (8 * (int)(offset & ~PackIndexV2.IS_O64)); offset = NB.DecodeUInt64(this._enclosing.offset64, idx); } this.entry.offset = offset; this.levelTwo += Constants.OBJECT_ID_LENGTH / 4; this.returnedNumber++; return(this.entry); } this.levelTwo = 0; } throw new NoSuchElementException(); }
protected override MutableEntry InnerNext(MutableEntry entry) { for (; _levelOne < _index._names.Length; _levelOne++) { if (_levelTwo < _index._names[_levelOne].Length) { int idx = _levelTwo / (Constants.OBJECT_ID_LENGTH / 4) * 4; long offset = NB.DecodeUInt32(_index._offset32[_levelOne], idx); if ((offset & IS_O64) != 0) { idx = (8 * (int)(offset & ~IS_O64)); offset = NB.DecodeUInt64(_index._offset64, idx); } entry.Offset = offset; _levelTwo += Constants.OBJECT_ID_LENGTH / 4; ReturnedNumber++; return(entry); } _levelTwo = 0; } throw new IndexOutOfRangeException(); }