Simple dictionary in C++

前端 未结 8 1214

Moving some code from Python to C++.

BASEPAIRS = { \"T\": \"A\", \"A\": \"T\", \"G\": \"C\", \"C\": \"G\" }

Thinking maps might be overkill? W

8条回答
  •  自闭症患者
    2021-01-30 16:57

    BASEPAIRS = { "T": "A", "A": "T", "G": "C", "C": "G" } What would you use?

    Maybe:

    static const char basepairs[] = "ATAGCG";
    // lookup:
    if (const char* p = strchr(basepairs, c))
        // use p[1]
    

    ;-)

提交回复
热议问题