`

Buffer

 
阅读更多

4 attributes of Buffer

 

capacity -- the size of buffer

limit -- 1st element is used to store how many elements are there in the buffer

position -- current position to be read or written. (Just let the notion of Iterator, when you call iter.next())

mark -- util attribute, very useful for programmer. 

 

 [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]

                               ^                                               ^

                               position=16                              limit=40

mark may = 8                                                          capacity=40

 

flip() --- change from fill state to drain state

and rewind()

 

flip() does 2 things:
1)      set limit to current position.     somthing similiar to string.trim()
2)      set position to 0

 

So, call flip() twice will make the current buffer zero-sized. Rewind() only set position to 0.

 

flip means flip from fill state to drain state.

 

buffer.flip() <==> buffer.limit(buffer.position()).position(0);

 

hasRemaining() --- tell you if you’ve reached the buffer’s limit when draining.

 

remaining() --- tell you the number of elements that remain from the current position to the limit.

 

clear() – resets a buffer to an empty state.

 

compact() – change from drain state to fill state

 

mark() – use current position to define mark  (rewind(), clear(), flip() will discard the mark )

 

reset() – sets the position to the current mark.  (if mark is undefined, throw exception)

 

hasArray() – tell you if the buffer has an accessible backing array or not.

 

array() – returns a reference to the array storage used by the buffer object if hasArray() returns true.

 

分享到:
评论

相关推荐

    netty-buffer-4.1.68.Final-API文档-中文版.zip

    赠送jar包:netty-buffer-4.1.68.Final.jar; 赠送原API文档:netty-buffer-4.1.68.Final-javadoc.jar; 赠送源代码:netty-buffer-4.1.68.Final-sources.jar; 赠送Maven依赖信息文件:netty-buffer-4.1.68.Final....

    netty-buffer-4.1.73.Final-API文档-中文版.zip

    赠送jar包:netty-buffer-4.1.73.Final.jar; 赠送原API文档:netty-buffer-4.1.73.Final-javadoc.jar; 赠送源代码:netty-buffer-4.1.73.Final-sources.jar; 赠送Maven依赖信息文件:netty-buffer-4.1.73.Final....

    环形buffer无锁一线程写一线程读

    如果你在找一个环形buffer这就是你想要的了。使用场景为一个线程写一个线程读完全不需要锁。可以设定buffer的初始块及数量,初始块是固定大小的,当需要扩环时会动态创建块即不像其它的库块满了就写失败了,当释放时...

    RingBuffer 循环缓存 亲测可用 V2 修改一处

    4.当写入数据的长度大于ringbuffer的可写入长度时,多余的数据将会丢弃。所以写入数据前,先判断ringbuffer的可写入长度。另外程序包含示例。 支持windows平台的vs与linux平台的clion,语言级别实现,与平台无关。 ...

    图像空间的消隐算法Zbuffer扫描线PPT教案.pptx

    "图像空间的消隐算法Zbuffer扫描线PPT教案" 本次课程主要讲解了图像空间的消隐算法,特别是Zbuffer扫描线算法。消隐算法是计算机图形学中一种重要的技术,用于解决三维物体的可见性问题。 消隐算法的分类可以分为...

    oracle性能调优之buffer cache

    Oracle 性能调优之 Buffer Cache Buffer Cache 是 Oracle 中的一种缓存机制,负责将磁盘上的数据 block 读取到内存中,以提高数据库的访问速度。在本文中,我们将详细介绍 Buffer Cache 的工作原理、状态、管理和...

    netty-buffer-4.1.11.Final-API文档-中文版.zip

    赠送jar包:netty-buffer-4.1.11.Final.jar; 赠送原API文档:netty-buffer-4.1.11.Final-javadoc.jar; 赠送源代码:netty-buffer-4.1.11.Final-sources.jar; 赠送Maven依赖信息文件:netty-buffer-4.1.11.Final....

    C语言头文件 BUFFER

    C语言头文件 BUFFERC语言头文件 BUFFERC语言头文件 BUFFERC语言头文件 BUFFERC语言头文件 BUFFERC语言头文件 BUFFERC语言头文件 BUFFERC语言头文件 BUFFERC语言头文件 BUFFERC语言头文件 BUFFERC语言头文件 BUFFERC...

    netty-buffer-4.1.23.Final-API文档-中文版.zip

    赠送jar包:netty-buffer-4.1.23.Final.jar; 赠送原API文档:netty-buffer-4.1.23.Final-javadoc.jar; 赠送源代码:netty-buffer-4.1.23.Final-sources.jar; 赠送Maven依赖信息文件:netty-buffer-4.1.23.Final....

    netty-buffer-4.1.27.Final-API文档-中文版.zip

    赠送jar包:netty-buffer-4.1.27.Final.jar; 赠送原API文档:netty-buffer-4.1.27.Final-javadoc.jar; 赠送源代码:netty-buffer-4.1.27.Final-sources.jar; 赠送Maven依赖信息文件:netty-buffer-4.1.27.Final....

    buffer应用缓冲区

    buffer应用缓冲区 socket应用层

    01 Protocol Buffer技术详解(语言规范).doc

    Protocol Buffer 技术详解(语言规范) Protocol Buffer 是一种语言中立、平台中立、可扩展的序列化数据格式,用于在通信网络和数据存储中交换结构化数据。Protocol Buffer 技术的主要优点是可以在不同的语言和平台...

    netty-buffer-4.1.24.Final-API文档-中文版.zip

    赠送jar包:netty-buffer-4.1.24.Final.jar; 赠送原API文档:netty-buffer-4.1.24.Final-javadoc.jar; 赠送源代码:netty-buffer-4.1.24.Final-sources.jar; 赠送Maven依赖信息文件:netty-buffer-4.1.24.Final....

    Z-BUFFER算法实现

    利用OPENGL绘制立方体 Z-BUFFER算法实现 可用鼠标和键盘控制立方体旋转

    Rt-thead studio软件下使用ringbuffer

    Rt-thead studio软件下使用ringbuffer

    netty-buffer-4.1.11.Final-API文档-中英对照版.zip

    赠送jar包:netty-buffer-4.1.11.Final.jar; 赠送原API文档:netty-buffer-4.1.11.Final-javadoc.jar; 赠送源代码:netty-buffer-4.1.11.Final-sources.jar; 赠送Maven依赖信息文件:netty-buffer-4.1.11.Final....

    netty-buffer-4.1.65.Final-API文档-中文版.zip

    赠送jar包:netty-buffer-4.1.65.Final.jar; 赠送原API文档:netty-buffer-4.1.65.Final-javadoc.jar; 赠送源代码:netty-buffer-4.1.65.Final-sources.jar; 赠送Maven依赖信息文件:netty-buffer-4.1.65.Final....

    Lab1-Buffer OverFlow

    Lab1-Buffer OverFlow,包含代码、实验说明和论文。

    ArcMap中Buffer的创建及使用

    介绍ArcMap中Buffer的创建及使用,并且附图说明。

    Protocol_Buffer官网文档中文版

    Protocol_Buffer官网文档中文版

Global site tag (gtag.js) - Google Analytics