怎样才能使一个算法用于不同的数据结构?# Java - 爪哇娇娃
w*r
1 楼
I stuck at a problem in how to implement a algorithm(simulate annealling)
in java.
I want to apply this algorithm to different datastructure(not different
object, I find visitor pattern cannot be used here). For example, pass a data
structure A to algorithm F, F will generate many A and does the algorithm on
A. It need to mutate A, clone A, get fitness of A. If we pass another data
structure B to F, then F will do all those things on B. Suppose B has those
methods including mutate, clone,
in java.
I want to apply this algorithm to different datastructure(not different
object, I find visitor pattern cannot be used here). For example, pass a data
structure A to algorithm F, F will generate many A and does the algorithm on
A. It need to mutate A, clone A, get fitness of A. If we pass another data
structure B to F, then F will do all those things on B. Suppose B has those
methods including mutate, clone,