Libraryless. Click here for Pure Java version (2264L/14K/52K).
1 | !7 |
2 | |
3 | p { |
4 | CircularFifoBuffer<Character> b = new CircularFifoBuffer<Character>(4); |
5 | b.add('k'); b.add('i'); b.add('l'); b.add('l'); b.add('l'); |
6 | S s = getLast(b, 4); |
7 | assertEqualsVerbose("illl", s); |
8 | assertEqualsVerbose(1L, b.getBase()); |
9 | } |
10 | |
11 | static S getLast(CircularFifoBuffer<Character> b, int n) { |
12 | n = Math.min(n, b.size()); |
13 | new StringBuilder buf; |
14 | Iterator<Character> it = b.getBackingStore().descendingIterator(); |
15 | for (int i = 0; i < n; i++) |
16 | buf.append(it.next()); |
17 | return buf.reverse().toString(); |
18 | } |
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1000775 |
Snippet name: | Test CircularFifoBuffer |
Eternal ID of this version: | #1000775/4 |
Text MD5: | a9e142d0b3d186b460de291db6c72ce9 |
Transpilation MD5: | c69dc56cb9fff4196d039f8131d549a5 |
Author: | stefan |
Category: | |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-10-19 23:32:47 |
Source code size: | 536 bytes / 18 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 748 / 828 |
Version history: | 3 change(s) |
Referenced in: | [show references] |