本文整理汇总了C#中System.ByteBuffer.Rewind方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.Rewind方法的具体用法?C# ByteBuffer.Rewind怎么用?C# ByteBuffer.Rewind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ByteBuffer
的用法示例。
在下文中一共展示了ByteBuffer.Rewind方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: relGet
private static void relGet(ByteBuffer b, int start)
{
int n = b.Remaining;
byte v;
for (int i = start; i < n; i++)
ck(b, (long)b.Get(), (long)((byte)Ic(i)));
b.Rewind();
}
示例2: absGet
private static void absGet(ByteBuffer b)
{
int n = b.Capacity;
byte v;
for (int i = 0; i < n; i++)
ck(b, (long)b.Get(), (long)((byte)Ic(i)));
b.Rewind();
}
示例3: ParseBody
protected override void ParseBody(ByteBuffer buf)
{
// 判断搜索是否已经结束
if (!buf.HasRemaining() || buf.Get() == 0x2D && buf.Get() == 0x31)
{
Finished = true;
return;
}
buf.Rewind();
// 只要还有数据就继续读取下一个friend结构
Users = new List<UserInfo>();
while (buf.HasRemaining())
{
UserInfo ui = new UserInfo();
ui.Read(buf);
// 添加到list
Users.Add(ui);
}
}
示例4: read
/**
* Reads GIF image from byte array
*
* @param data containing GIF file.
* @return read status code (0 = no errors)
*/
public int read(byte[] data)
{
init();
if (data != null)
{
//Initiliaze the raw data buffer
rawData = ByteBuffer.Wrap(data);
rawData.Rewind();
rawData.Order(ByteOrder.LittleEndian);
readHeader();
if (!err())
{
readContents();
if (frameCount < 0)
{
status = STATUS_FORMAT_ERROR;
}
}
}
else {
status = STATUS_OPEN_ERROR;
}
return status;
}
示例5: test
public static void test(int level, ByteBuffer b, bool direct)
{
Show(level, b);
if (direct != b.IsDirect)
fail("Wrong direction", b);
// Gets and puts
relPut(b);
relGet(b);
absGet(b);
bulkGet(b);
absPut(b);
relGet(b);
absGet(b);
bulkGet(b);
bulkPutArray(b);
relGet(b);
bulkPutBuffer(b);
relGet(b);
// Compact
relPut(b);
b.Position = (13);
b.Compact();
b.Flip();
relGet(b, 13);
// Exceptions
relPut(b);
b.Limit = (b.Capacity / 2);
b.Position = (b.Limit);
tryCatch(b, typeof(BufferUnderflowException), () =>
{
b.Get();
});
tryCatch(b, typeof(BufferOverflowException), () =>
{
b.Put((byte)42);
});
// The index must be non-negative and lesss than the buffer's limit.
tryCatch(b, typeof(IndexOutOfRangeException), () =>
{
b.Get(b.Limit);
});
tryCatch(b, typeof(IndexOutOfRangeException), () =>
{
b.Get(-1);
});
tryCatch(b, typeof(IndexOutOfRangeException), () =>
{
b.Put(b.Limit, (byte)42);
});
tryCatch(b, typeof(InvalidMarkException), () =>
{
b.Position = (0);
b.Mark();
b.Compact();
b.Reset();
});
// Values
b.Clear();
b.Put((byte)0);
b.Put(unchecked((byte)-1));
b.Put((byte)1);
b.Put(unchecked((byte)sbyte.MaxValue));
b.Put(unchecked((byte)sbyte.MinValue));
byte v;
b.Flip();
ck(b, b.Get(), 0);
ck(b, b.Get(), unchecked((byte)-1));
ck(b, b.Get(), 1);
ck(b, b.Get(), unchecked((byte)sbyte.MaxValue));
ck(b, b.Get(), unchecked((byte)sbyte.MinValue));
// Comparison
b.Rewind();
ByteBuffer b2 = Lucene.Net.Support.ByteBuffer.Allocate(b.Capacity);
b2.Put(b);
b2.Flip();
b.Position = (2);
b2.Position = (2);
if (!b.Equals(b2))
{
//.........这里部分代码省略.........