Libraryless. Click here for Pure Java version (2212L/14K).
sbool makeNotifyingStringBufferRotate_verbose; sclass NotifyingStringBufferRotator implements Runnable { NotifyingStringBuffer buf; IF0<Int> getMaxChars; bool processing; // avoid endless loop *(NotifyingStringBuffer *buf, IF0<Int> *getMaxChars) {} run { if (processing) ret; temp tempSet(this, processing := true); Int max = callF(getMaxChars); //if (makeNotifyingStringBufferRotate_verbose) System.out.println("XX " + max + " " + buf.length()); if (max == null || buf.length() <= max) ret; if (makeNotifyingStringBufferRotate_verbose) print("Rotating NotifyingStringBuffer (" + buf.length() + "/" + max + ")"); try { int newLength = max/2; int ofs = buf.length()-newLength; S newString = buf.substring(ofs); buf.setLength(0); buf.append("[...] ").append(newString); } catch (Exception e) { buf.setLength(0); } buf.trimToSize(); } } svoid makeNotifyingStringBufferRotate(NotifyingStringBuffer buf, IF0<Int> getMaxChars) { if (hasElementWithClassShortNamed('NotifyingStringBufferRotator, buf.onChange)) ret; buf.onChange(new NotifyingStringBufferRotator(buf, getMaxChars)); }
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1024230 |
Snippet name: | makeNotifyingStringBufferRotate |
Eternal ID of this version: | #1024230/9 |
Text MD5: | 02f6f584f8cd479f19f9afd82a622cbc |
Transpilation MD5: | cb2ec6030c10ba3f40b0b62a856b4311 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-07-28 14:06:47 |
Source code size: | 1214 bytes / 34 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 339 / 1309 |
Version history: | 8 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |