Mercurial > hg > Database > jungle-sharp
view Main/jungle-main/DefaultJungle.cs @ 41:bd44baa491a9 default tip
add TestJungleCore.cs
author | Kazuma Takeda |
---|---|
date | Thu, 23 Feb 2017 17:19:55 +0900 |
parents | f2ea780b3e80 |
children |
line wrap: on
line source
using System.Collections; using System.Collections.Generic; using System; namespace JungleDB { public class DefaultJungle : Jungle { private Journal journal; private TreeMap <string, JungleTree> trees; private string uuid; private TreeEditor editor; public DefaultJungle(Journal journal, string uuid, TreeEditor editor){ this.journal = new NullJournal(); this.trees = new TreeMap <string, JungleTree>(); this.uuid = uuid; this.editor = editor; } public JungleTree getTreeByName(string name) { JungleTree jungle_tree = trees.get(name); if (jungle_tree != null) { return jungle_tree; } else { return null; } } public JungleTree createNewTree(string name) { ChangeList list = new InnerChangeList(uuid, name); DefaultTreeNode root = new DefaultTreeNode (); InterfaceTraverser traverser = new InterfaceTraverser (root, true); TreeContext tc = new DefaultTreeContext (root, null, list, uuid, name, 0, traverser); JungleTree newTree = new DefaultJungleTree (tc, uuid, journal.getWriter (), editor); if (newTree != null) { trees = trees.put (name, newTree); } else { } return newTree; } public class InnerChangeList : ChangeList { string uuid; string name; IEnumerator IEnumerable.GetEnumerator() { return this.GetEnumerator(); } public IEnumerator<TreeOperation> GetEnumerator() { return iterator (); } // construct public InnerChangeList(string _uuid, string _name) { this.uuid = _uuid; this.name = _name; } public IEnumerator<TreeOperation> iterator() { List<TreeOperation> nil = new List<TreeOperation>(); return nil.iterator(); } public string uuids() { return uuid; } public string getTreeName() { return name; } public TreeOperationLog getLog() { return new DefaultTreeOperationLog(); } } } }