mirror of https://github.com/zlatinb/muwire
store path elements or the item itself in the tree
parent
83680779f8
commit
1ee385b2ff
|
@ -37,7 +37,7 @@ class FileCollection {
|
||||||
name = files.first().pathElements.first()
|
name = files.first().pathElements.first()
|
||||||
tree = new PathTree(name)
|
tree = new PathTree(name)
|
||||||
for(FileCollectionItem item : files) {
|
for(FileCollectionItem item : files) {
|
||||||
tree.add(item.pathElements)
|
tree.add(item.pathElements, item)
|
||||||
}
|
}
|
||||||
|
|
||||||
byte [] signablePayload = signablePayload()
|
byte [] signablePayload = signablePayload()
|
||||||
|
@ -73,7 +73,7 @@ class FileCollection {
|
||||||
name = files.first().pathElements.first()
|
name = files.first().pathElements.first()
|
||||||
tree = new PathTree(name)
|
tree = new PathTree(name)
|
||||||
for(FileCollectionItem item : files) {
|
for(FileCollectionItem item : files) {
|
||||||
tree.add(item.pathElements)
|
tree.add(item.pathElements, item)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.hashCode = Objects.hash(timestamp, author, comment, files)
|
this.hashCode = Objects.hash(timestamp, author, comment, files)
|
||||||
|
|
|
@ -10,7 +10,7 @@ class PathTree {
|
||||||
keyToNode.put(this.root.key(), this.root)
|
keyToNode.put(this.root.key(), this.root)
|
||||||
}
|
}
|
||||||
|
|
||||||
void add(List<String> paths) {
|
void add(List<String> paths, FileCollectionItem item) {
|
||||||
PathNode current = null
|
PathNode current = null
|
||||||
for (String path : paths) {
|
for (String path : paths) {
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
|
@ -28,7 +28,9 @@ class PathTree {
|
||||||
current.children.add(child)
|
current.children.add(child)
|
||||||
}
|
}
|
||||||
current = keyToNode.get(childKey)
|
current = keyToNode.get(childKey)
|
||||||
|
current.userObject = path
|
||||||
}
|
}
|
||||||
|
current?.userObject = item
|
||||||
}
|
}
|
||||||
|
|
||||||
public void traverse(Callback cb) {
|
public void traverse(Callback cb) {
|
||||||
|
@ -51,6 +53,7 @@ class PathTree {
|
||||||
final PathNode parent
|
final PathNode parent
|
||||||
final Set<PathNode> children = new LinkedHashSet<>()
|
final Set<PathNode> children = new LinkedHashSet<>()
|
||||||
private final int hashCode
|
private final int hashCode
|
||||||
|
Object userObject
|
||||||
|
|
||||||
PathNode(String path, PathNode parent) {
|
PathNode(String path, PathNode parent) {
|
||||||
this.parent = parent
|
this.parent = parent
|
||||||
|
|
Loading…
Reference in New Issue