1818import java .util .Arrays ;
1919import java .util .HashMap ;
2020
21- /**
22- * BytesHeap provides a representation of a "heap" for use with the LTv2 file format.
23- */
21+ /** BytesHeap provides a representation of a "heap" for use with the LTv2 file format. */
2422public class BytesHeap {
25- private final HashMap <Entry ,Integer > cache = new HashMap <>();
23+ private final HashMap <Entry , Integer > cache = new HashMap <>();
2624 private byte [] bytes = new byte [256 ];
2725 private byte [] lengths = new byte [256 ];
2826 private int length ;
2927
3028 public BytesHeap () {
31- for (int i = 0 ; i != 65536 ; i ++) {
29+ for (int i = 0 ; i != 65536 ; i ++) {
3230 byte [] bytes = Util .long2TruncatedBytes (i );
3331 alloc (new Entry (bytes ));
3432 }
@@ -46,7 +44,7 @@ public int insert(byte[] key) {
4644 final Integer val = this .cache .get (e );
4745 // Check for exact match.
4846 if (val == null ) {
49- return alloc (e );
47+ return alloc (e );
5048 }
5149 //
5250 return val ;
@@ -61,7 +59,7 @@ public int insert(byte[] key) {
6159 public byte [] get (int index ) {
6260 int n = lengths [index ];
6361 byte [] slice = new byte [n ];
64- System .arraycopy (bytes ,index , slice ,0 , n );
62+ System .arraycopy (bytes , index , slice , 0 , n );
6563 return slice ;
6664 }
6765
@@ -102,25 +100,25 @@ private int alloc(Entry e) {
102100 return val ;
103101 }
104102
105- private static final class Entry {
106- private final byte [] bytes ;
103+ private static final class Entry {
104+ private final byte [] bytes ;
107105
108- public Entry (byte [] bytes ) {
109- this .bytes = bytes ;
110- }
106+ public Entry (byte [] bytes ) {
107+ this .bytes = bytes ;
108+ }
111109
112- @ Override
113- public boolean equals (Object o ) {
114- if (o instanceof Entry e ) {
115- return Arrays .equals (bytes , e .bytes );
116- }
117- //
118- return false ;
110+ @ Override
111+ public boolean equals (Object o ) {
112+ if (o instanceof Entry e ) {
113+ return Arrays .equals (bytes , e .bytes );
119114 }
115+ //
116+ return false ;
117+ }
120118
121- @ Override
122- public int hashCode () {
123- return Arrays .hashCode (bytes );
124- }
119+ @ Override
120+ public int hashCode () {
121+ return Arrays .hashCode (bytes );
125122 }
123+ }
126124}
0 commit comments