java - Use of recordAccess(this) in Entry<K, V> class -
while having inside hashmap class, came across method :-
/** * method invoked whenever value in entry * overwritten invocation of put(k,v) key k that's * in hashmap. */ void recordaccess(hashmap<k,v> m) { }
actually, method defined inside inner class of entry<k, v>
i'm not able make out of comment. method ?
ps : can see method being called inside's hashmap's putfornullkey() method
private v putfornullkey(v value) { (entry<k,v> e = table[0]; e != null; e = e.next) { if (e.key == null) { v oldvalue = e.value; e.value = value; e.recordaccess(this); // call return oldvalue; } } modcount++; addentry(0, null, value, 0); return null; }
update : i've updated first code snippet.
a linkedhashmap can have 2 orders: insertion order, or access order. if access order used, method makes sure accessed entry moved beginning of list.
Comments
Post a Comment