用于性能和低内存的 Patricia trie 节点结构

问题描述

有一段时间我试图实现一个 PatriciaTrie。我很难在两个 Node 结构之间进行选择,我不确定哪个将是性能和内存效率最高的。 一种是包含两个类,NodeEdge

public interface Edge {
    long getPath();

    byte getLength();

    Node getChild();
}

public interface Node {
    Edge getRightEdge();

    Edge getLeftEdge();
}

一个将只有 Node 本体。类似于以下内容

public interface Node {
    Node getLeftChild();
    Node getRightChild();
    
    byte getLeftLength();
    byte getRightLength();
    long getLeftPath();
    long getReftPath();
}

我的困境如下:

如果我们还考虑到 java 对象 headerpadding,第二个似乎内存效率更高。相反,从我的角度来看,第一个将更具可读性,我认为也有性能但不确定。那么您认为哪种模式更好?

任何帮助将不胜感激。

我还没有大量实现 Trie,这就是为什么提供的代码是抽象的。非常抱歉。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)