Why Java Collection Framework doesn't contain Tree and Graph

前端 未结 6 1921
太阳男子
太阳男子 2020-12-05 06:39

I am familiar with Java Collection Framework which contains basic interfaces: Collection and Map. I am wondering why the Framework doesn\'t contain

6条回答
  •  盖世英雄少女心
    2020-12-05 06:59

    I suspect that the answer is that it is a combination of two things:

    • A generic tree or graph interface would be "feature poor".
    • It is easier and more efficient to implement a tree or graph using fields to represent child and (if you need them) parent pointers.

    Note that neither Apache commons or Google commons have generic graph or tree support. However, I did come across a couple of generic tree/graph hierarchies:

    • The jsfcompounds project on JavaNet has the "com.truchsess.util" graph and tree framework.
    • The OpenJGraph project (inactive) on SourceForge includes tree and graph libraries.

提交回复
热议问题