419: out.writeInt(maxSize);
420: super.doWriteObject(out);
421: }
422:
423: /**
424: * Reads the data necessary for
put() to work in the superclass.425: */
426: protected void doReadObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
428: super.doReadObject(in);
429: }
430:
431: }
部分操作需要追溯其父类代码,这里就不贴了,有兴趣的朋友可以直接到源码阅读。
LRUMap对于构建缓存或者连接池之类的技术经常用到,common-collections框架给了现成的实现,大家在不需要修改的情况下,完全可以不必reinvent the wheel,直接用,好用且稳定。
摘自 Change Dir