diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2010-03-14 23:58:16 +0000 |
|---|---|---|
| committer | Krzysztof KosiĆski <tweenk.pl@gmail.com> | 2010-03-14 23:58:16 +0000 |
| commit | bf83d5a03bf856e34bd0a6e2656a5b2dcfe8aafb (patch) | |
| tree | 89db1a5074e284c958cf693302beaaafb086b702 /src/algorithms/longest-common-suffix.h | |
| parent | Translations. Polish translation update. (diff) | |
| download | inkscape-bf83d5a03bf856e34bd0a6e2656a5b2dcfe8aafb.tar.gz inkscape-bf83d5a03bf856e34bd0a6e2656a5b2dcfe8aafb.zip | |
Move around files to remove some vanity directories.
Also remove the obsolete IDL file stub.
(bzr r9194)
Diffstat (limited to 'src/algorithms/longest-common-suffix.h')
| -rw-r--r-- | src/algorithms/longest-common-suffix.h | 114 |
1 files changed, 0 insertions, 114 deletions
diff --git a/src/algorithms/longest-common-suffix.h b/src/algorithms/longest-common-suffix.h deleted file mode 100644 index 04d2b179d..000000000 --- a/src/algorithms/longest-common-suffix.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Inkscape::Algorithms::longest_common_suffix - * - * Authors: - * MenTaLguY <mental@rydia.net> - * - * Copyright (C) 2004 MenTaLguY - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef SEEN_INKSCAPE_ALGORITHMS_LONGEST_COMMON_SUFFIX_H -#define SEEN_INKSCAPE_ALGORITHMS_LONGEST_COMMON_SUFFIX_H - -#include <iterator> -#include <functional> -#include "util/list.h" - -namespace Inkscape { - -namespace Algorithms { - -/** - * Time costs: - * - * The case of sharing a common successor is handled in O(1) time. - * - * If \a a is the longest common suffix, then runs in O(len(rest of b)) time. - * - * Otherwise, runs in O(len(a) + len(b)) time. - */ - -template <typename ForwardIterator> -ForwardIterator longest_common_suffix(ForwardIterator a, ForwardIterator b, - ForwardIterator end) -{ - typedef typename std::iterator_traits<ForwardIterator>::value_type value_type; - return longest_common_suffix(a, b, end, std::equal_to<value_type>()); -} - -template <typename ForwardIterator, typename BinaryPredicate> -ForwardIterator longest_common_suffix(ForwardIterator a, ForwardIterator b, - ForwardIterator end, BinaryPredicate pred) -{ - if ( a == end || b == end ) { - return end; - } - - /* Handle in O(1) time the common cases of identical lists or tails. */ - { - /* identical lists? */ - if ( a == b ) { - return a; - } - - /* identical tails? */ - ForwardIterator tail_a(a); - ForwardIterator tail_b(b); - if ( ++tail_a == ++tail_b ) { - return tail_a; - } - } - - /* Build parallel lists of suffixes, ordered by increasing length. */ - - using Inkscape::Util::List; - using Inkscape::Util::cons; - ForwardIterator lists[2] = { a, b }; - List<ForwardIterator> suffixes[2]; - - for ( int i=0 ; i < 2 ; i++ ) { - for ( ForwardIterator iter(lists[i]) ; iter != end ; ++iter ) { - if ( iter == lists[1-i] ) { - // the other list is a suffix of this one - return lists[1-i]; - } - - suffixes[i] = cons(iter, suffixes[i]); - } - } - - /* Iterate in parallel through the lists of suffix lists from shortest to - * longest, stopping before the first pair of suffixes that differs - */ - - ForwardIterator longest_common(end); - - while ( suffixes[0] && suffixes[1] && - pred(**suffixes[0], **suffixes[1]) ) - { - longest_common = *suffixes[0]; - ++suffixes[0]; - ++suffixes[1]; - } - - return longest_common; -} - -} - -} - -#endif /* !SEEN_INKSCAPE_ALGORITHMS_LONGEST_COMMON_SUFFIX_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : |
