com.zpf.tool.MethodUtil Maven / Gradle / Ivy
package com.zpf.tool;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.LinkedList;
public class MethodUtil {
private static class Entry {
LinkedList
nodeList = new LinkedList<>();
V tempValue = null;
}
public static
V cps(P original, INodeManager
nv) {
Entry
entry = new Entry<>();
entry.tempValue = nv.addNodeValue(original, entry.tempValue);
nv.addChildNode(original, entry.nodeList);
while (entry.nodeList.size() > 0) {
P n = entry.nodeList.pollFirst();
entry.tempValue = nv.addNodeValue(n, entry.tempValue);
nv.addChildNode(n, entry.nodeList);
}
return entry.tempValue;
}
public interface INodeManager
{
@Nullable
V addNodeValue(@Nullable P node, @Nullable V value);
void addChildNode(@Nullable P node, @NonNull LinkedList
nodeList);
}
}