mclow / Boost.Algorithm

Proposed Boost.Algorithm Library
7 stars 2 forks source link

Adding is_palindromic() algo to Boost.Algorithm #21

Open zamazan4ik opened 8 years ago

zamazan4ik commented 8 years ago

Hello. I implemented is_palindromic() algo for Boost.Algorithm.

The algorithm compares container from two sides. You can use custom comparator. Also supported Boost.Range. Complexity is O(N).

Using is easy: you should give two bidirectional or most powerful iterators for [begin, end) and you may give custom comparator.

Result is bool.

Maybe you have some additions to this algorithm?

Best regards, Zaitsev Alexander.

mclow commented 8 years ago

Needs tests ;-) Off the top of my head, it needs tests for: zero element input, single element, odd #, even #. That would be a good start.

The tests should exercise both the version that uses operator== and the one that takes a comparison functor explicitly.

zamazan4ik commented 8 years ago

I tested it on tests like that: zero element input, single element, odd and even. Also I tested on set of random strings. Should I add my tests to tests on GitHub?

mclow commented 8 years ago

Yes. The tests should be part of the pull request. Also, documentation.

mclow commented 8 years ago

You can get most of the documentation that you want by putting doxygen comments in the source, but you'll have to write a description, rationale, etc.

mclow commented 8 years ago

in your documentation, there should be "What should you use this for"? (so, real-world examples).

zamazan4ik commented 8 years ago

Can I use in tests C++14?

mclow commented 8 years ago

I would not if I were you; that would limit the people who run the tests. I don't see anything in the code you have that uses c++14.

zamazan4ik commented 8 years ago

You can't see it - it's not yet in the repo. It's my code for testing(using auto in arguments in lambda). Ok, I'll not use C++14. What about C++11? I think, it's widespread compiler.

zamazan4ik commented 8 years ago

Can you send me your config file for doxygen? Because i don't know about style of Boost's documentation.

zamazan4ik commented 8 years ago

I have done examples, tests and documentation. What should i do next?

mclow commented 8 years ago

This is looking good. Two comments: why call it is_palindromic, rather than just is_palindrome? That's a simpler name. What do you think?

Also, in the docs, you write:

The header file 'is_palindromic.hpp' contains four variants of a single algorithm, is_palindromic. The algorithm tests the sequence and returns true if the sequence is palindromic.

That doesn't really tell the reader anything. I think that this would be better:

The header file 'is_palindromic.hpp' contains four variants of a single algorithm, is_palindromic. The algorithm tests the sequence and returns true if the sequence is a palindrome; i.e, it is identical when traversed either backwards or frontwards.

(basically insert a definition of what a palindrome is)

zamazan4ik commented 8 years ago

Yes, i agree with your additions.

zamazan4ik commented 8 years ago

I wrote 'is_palindromic' because before aming of function i discuss about this with some other people. And first variant was 'is_palindromic'. But your variant is better, from my point of view. I don't know, why i didn't name function 'is_plaindrome' before your comment.

I rewrited name of function in the implementation, examples, tests, documents.

Something else?

mclow commented 8 years ago

Ok; I think this is ready to commit. However, I'll be committing it manually, because this isn't the right place for it. My personal repo is different from the boost one. This should be committed to https://github.com/boostorg/algorithm:develop

zamazan4ik commented 8 years ago

ok. For every next set of features should i create a new feature branch?