📄 nonemptybookmarks.java
字号:
// a recursive data structure that stores a list of bookmarksclass NonemptyBookmarks extends EmptyBookmarks { private EmptyBookmarks rest; private Bookmark first; private int mysize; public NonemptyBookmarks(EmptyBookmarks list, Bookmark entry) { rest = list; first = entry; mysize = rest.getSize() + 1; } // if this bookmark is at the desired position, return it, // otherwise decrement the desired position and pass the call // on to the rest of the list public Bookmark getSelectedItem( int position ) { if ( position == 0 ) return first; else try { return rest.getSelectedItem( position-1); }catch (IllegalArgumentException e) { throw new IllegalArgumentException("Index "+position+" is out of range"); } } public int getSize() { return mysize; } public boolean isemtpy() { return false; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -