开发者

Libraries for Algorithms [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 9 years ago.

Are there any libraries/sdk/etc that 'allow' to use algorithms in your programs without any difficulty? The following code may describe my question better(I need something like this):

algorithm* a = new search_algorithm("binary_search");
a->set_data("some text to 开发者_开发知识库be searched");
search_result_t r = a->search("this_text");

Thanks for response.

P.S. Thanks all, but I've "heard" about the STL and Boost. I used a simple example above, but "in my dreams" I want to get this, too:

algorithm* a = new search_algorithm("boyer_moore");
//...
a = new graph_algorithm("brent");
a->set_graph(/*graph_t*/gt);
a->detect_cycles(...);

or even this:

a = new tree_algorithm("kruskal");
tree_t* mt = new tree_t(...);
a->set_tree(mt);
a->get_min_spanning_tree(...);


You've 'heard' of Boost and STL_, so I assume you've heard of

  • boyer-moore,
  • min spanning tree,
  • Brent's algorithm

What is it, exactly, that you are missing?


you can use the 'STL: algorithms' and the boost library. It doesn't always contain what you are looking for but that is because a lot of stuff has to be custom made for your dataset.


The standard library already includes templates for a number of algorithms (including binary search). With the minor proviso that a binary search won't work in the example you've given (it requires sorted input), it's actually even easier than you've shown:

int values[] = { 1, 3, 4, 5, 8, 9};

int *pos = std::lower_bound(values, values+6, 5);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜