代码之家  ›  专栏  ›  技术社区  ›  roundcrisis

处理代码中的数据层次结构

  •  0
  • roundcrisis  · 技术社区  · 16 年前

    所以,假设我有一个字符串要用一个映射到树状数据结构的给定格式进行解析。字符串类似于文件夹路径,结构类似于文件结构,只是它有一些规则

    something@cat1@otherSomething

     /something/cat1/otherSomething 
    

    为了something@cat2@otherSomething

     /something/cat2/otherSomething
    

    其他例子

    /OtherThing/cat1/otherSomething/Blah
    /OtherThing/cat4/otherSomething
    

    有一些规则可以控制哪些子类别是有效的,哪些子类别是不可接受的,目前我正在考虑一个重对象层次结构,但我知道这不是一个灵活的解决方案,我更希望类别是一个更一般的,但再次,因为有什么规则可以下一步我不知道如何做到这一点。

    规则的示例可以是: 另一件事 只能有子类别cat1和cat4(其他任何内容都无效)

    谢谢

    1 回复  |  直到 16 年前
        1
  •  0
  •   roundcrisis    16 年前

    我想我应该收集一些儿童类型