Mercurial > hg > Members > shoshi > TreeCMSv2
diff src/treecms/memory/OnMemoryTree.java @ 6:12604eb6b615
added javadoc
author | shoshi |
---|---|
date | Mon, 14 Mar 2011 23:24:38 +0900 |
parents | f5ed85be5640 |
children | fc19e38b669b |
line wrap: on
line diff
--- a/src/treecms/memory/OnMemoryTree.java Tue Mar 01 01:29:59 2011 +0900 +++ b/src/treecms/memory/OnMemoryTree.java Mon Mar 14 23:24:38 2011 +0900 @@ -51,56 +51,4 @@ return m_table.get(_uuid); } - @Override - public synchronized Node updateTree(Node _target,NodeData _newData) - { - LinkedList<OnMemoryNode> path = findAndClone(m_root,(OnMemoryNode)_target,_newData); - - if(path == null) - { - //not found. - return null; - } - - m_root = path.peekFirst(); - return path.peekLast(); - } - - OnMemoryNode cloneNode(OnMemoryNode _target,NodeData _newData) - { - OnMemoryNode clone = m_forest.createNode(_target.getID().update(),_newData); - m_table.put(clone.getID().getUUID(),clone); - return clone; - } - - LinkedList<OnMemoryNode> findAndClone(OnMemoryNode _parent,OnMemoryNode _target,NodeData _newData) - { - if(_parent.getID().isFamily(_target.getID())){ - //find. - LinkedList<OnMemoryNode> path = new LinkedList<OnMemoryNode>(); - OnMemoryNode clone = cloneNode((OnMemoryNode)_parent,_newData); - path.addFirst(clone); - return path; - } - - for(Node child : _parent.getData().list()){ - LinkedList<OnMemoryNode> path = findAndClone((OnMemoryNode)child,_target,_newData); - if(path != null){ - OnMemoryNode clone = cloneNode((OnMemoryNode)_parent,null); - clone.getData().list().remove(child); - clone.getData().list().add(path.peekFirst()); - path.addFirst(clone); - return path; - } - } - - return null; //not found. - } - - @Override - public Node getRoot() - { - return m_root; - } - }