text:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>

<template id="header_footer_custom" inherit_id="website.footer_default"
    name="Footer Questions Link">
    <xpath expr="//ul[@id='products']" position="inside">

Q&A

Forums

    </xpath>
</template>

<template id="link_button">
    <form method="POST" t-att-action="url">
        <button t-attf-class="fa btn-link #{classes} #{karma and 'karma_required text-muted' or ''}" t-attf-data-karma="#{karma}">
            <t t-esc="label"/></button>
    </form>
</template>

<template id="assets_frontend" inherit_id="website.assets_frontend" name="website_forum assets">
    <xpath expr="." position="inside">
        <link rel='stylesheet' href="/web/static/lib/jquery.textext/jquery.textext.css"/>
        <link rel='stylesheet' href='/website_forum/static/src/css/website_forum.css'/>

        </t>

                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#oe-help-navbar-collapse">
                        Toggle navigation

                    </button>

                            Questions

                            People

                            Tags

                            Badges

                            My Profile

                    <form class="navbar-form navbar-right" role="search" t-attf-action="/forum/#{ slug(forum) }" method="get">

                            <input type="search" class="form-control"
                                name="search" placeholder="Search a question..."
                                t-att-value="search or ''"/>
                            <button type="submit" class="btn btn-default">Search</button>

                    </form>

                        <button type="button" class="close notification_close" t-att-id="notification.id" data-dismiss="alert" aria-hidden="true">&times;</button>

                        View Your Badges

                        <button type="button" class="close validation_email_close" data-dismiss="alert" aria-hidden="true">&times;</button>

                                It appears your email has not been verified.
                                Click here to send a verification email allowing you to participate to the forum.

                        <button type="button" class="close validated_email_close" data-dismiss="alert" aria-hidden="true">&times;</button>

Congratulations! Your email has just been validated. You may now participate to our forums.

                    <t t-raw="0"/>

                    Ask a Question

Keep Informed

                            <t t-call="website_mail.follow">
                                <t t-set="email" t-value="user.email"/>
                                <t t-set="object" t-value="forum"/>
                            </t>

About This Forum

                            <t t-raw="forum.description"/>
                             Read Guidelines
                             Back to

Question tools

                                <t t-call="website_mail.follow"><t t-set="object" t-value="question"/></t>

                                    <t t-raw="len(question.message_follower_ids)"/> follower(s)

Stats

 Asked:

 Seen: <t t-raw="question.views"/>
                                        times
                                        time

 Last updated:

    </t>
</template>

<template id="display_post">

Answers

Answer

                     [Deleted]
                     [Closed]

            <t t-foreach="question.tag_ids" t-as="question_tag">

            </t>

                by
                on

                    <t t-if="question.child_count>1">answers</t>
                    <t t-if="question.child_count==1">answers</t>

                with  views
                 and

                    <t t-if="question.vote_count>1">votes</t>
                    <t t-if="question.vote_count==1">vote</t>

</template>

<template id="display_post_answer">

            <t t-if="len(answer.website_message_ids)>0">
                (<t t-esc="len(answer.website_message_ids)"/>
                <t t-if="len(answer.website_message_ids)>1">Comments</t>
                <t t-if="len(answer.website_message_ids)<=1">Comment</t>)
            </t>

</template>

<template id="faq">
    <t t-call="website_forum.header">

    </t>
</template>

<template id="forum_all">
    <t t-call="website.layout">

Our forums

    </t>
</template>

<template id="forum_index" name="Forum">
    <t t-call="website_forum.header">

            <t t-esc="question_count"/> Questions
            <t t-esc="search"/>

                  <t t-if="filters == 'all'">All</t>
                  <t t-if="filters == 'unanswered'">Unanswered</t>
                  <t t-if="filters == 'followed'">Followed</t>
                  <t t-if="tag"></t>
                  <t t-if="sorting == 'date'"> by activity date</t>
                  <t t-if="sorting == 'creation'"> by creation date</t>
                  <t t-if="sorting == 'answered'"> by most answered</t>
                  <t t-if="sorting == 'vote'"> by most voted</t>

Filter on

                      All

                      Unanswered

                      Followed

Tags

                      <t t-esc="tag.name"/>

Sort by

                      Last activity date

                      Newest

                      Most answered

                      Most voted

            <t t-call="website_forum.display_post"/>

        <t t-call="website.pager"/>
    </t>
</template>

<template id="404">
    <t t-call="website_forum.header">

Question not found!

Sorry, this question is not available anymore.

            Return to the question list.

    </t>
</template>

<template id="ask_question">
    <t t-call="website_forum.header">

Ask your Question

 please, try to make your question interesting to others

 provide enough details and, if possible, give an example

 be clear and concise, avoid unnecessary introductions (Hi, ... Thanks...)

        <form t-attf-action="/forum/#{ slug(forum) }/question/new" method="post" role="form" class="tag_text">
            <input type="text" name="question_name" required="True" t-attf-value="#{question_name}"
                class="form-control" placeholder="Enter your Question"/>

Please enter a descriptive question (should finish with a '?')

            <input type="hidden" name="karma" t-attf-value="#{user.karma}" id="karma"/>
            <textarea name="content" required="True" class="form-control load_editor">
                <t t-esc="question_content"/>
            </textarea>

            <input type="text" name="question_tags" placeholder="Tags" class="form-control load_tags"/>

            <button t-attf-class="btn btn-primary #{(user.karma < forum.karma_ask) and 'karma_required' or ''}"
                id="btn_ask_your_question" t-att-data-karma="forum.karma_ask">Post Your Question</button>
        </form>

    </t>
</template>

<template id="edit_post">
    <t t-call="website_forum.header">

Edit question

Edit answer

        <form t-attf-action="/forum/#{slug(forum)}/post/#{slug(post)}/save" method="post" role="form" class="tag_text">

                <input type="text" name="question_name" id="question_name" required="True"
                    t-attf-value="#{post.name}" class="form-control" placeholder="Edit your Question"/>

Please enter a descriptive question (should finish by a '?')

            <input type="hidden" name="karma" t-attf-value="#{user.karma}" id="karma"/>
            <textarea name="content" required="True" class="form-control load_editor">
                <t t-esc="post.content"/>
            </textarea>

                <input type="text" name="question_tag" class="form-control col-md-9 load_tags" placeholder="Tags" t-attf-value="#{tags}"/>

            <button class="btn btn-primary btn-lg">Save</button>
        </form>

    </t>
</template>

<template id="close_question">
    <t t-call="website_forum.header">

Close question

            If you close this question, it will be hidden for most users. Only
            users having a high karma can see closed questions to moderate
            them.

        <form t-attf-action="/forum/#{ slug(forum) }/question/#{slug(question)}/close" method="post" role="form" class="form-horizontal mt32 mb64">
            <input name="post_id" t-att-value="question.id" type="hidden"/>

                Question:

                Reason:

                    <select class="form-control" name="reason_id">
                        <t t-foreach="reasons or []" t-as="reason">
                            <option t-att-value="reason.id" t-att-selected="reason.id == question.closed_reason_id.id"><t t-esc="reason.name"/></option>
                        </t>
                    </select>

                    <button class="btn btn-primary">Close question</button>
                    or
                    back to question

        </form>
    </t>
</template>

<template id="post_answer">

Your answer

        Please try to give a substantial answer. If you wanted to comment on the question or answer, just
        use the commenting tool. Please remember that you can always revise your answers
        - no need to answer the same question twice. Also, please don't forget to vote
        - it really helps to select the best questions and answers!

    <form t-attf-action="/forum/#{ slug(forum) }/post/#{slug(question)}/new" method="post" role="form">
        <input type="hidden" name="karma" t-attf-value="#{user.karma}" id="karma"/>
        <textarea name="content" class="form-control load_editor" required="True"/>
        <button t-attf-class="btn btn-primary mt16 #{not question.can_answer and 'karma_required' or ''}"
                id="btn_ask_your_question" t-att-data-karma="question.karma_answer">Post Your Answer</button>
    </form>

</template>

<template id="vote">

            votes

            vote

</template>

<template id="post_description_full" name="Question Navigation">
    <t t-call="website_forum.header">

                <t t-call="website_forum.vote">
                    <t t-set="post" t-value="question"/>
                </t>

                     Views

                     [Deleted]
                     [Closed]

                        The question has been closed<t t-if="question.closed_reason_id"> for reason: </t>

                    <t t-if="question.closed_uid">
                        by
                    </t>
                    on

                        <t t-call="website_forum.link_button">
                            <t t-set="url" t-value="'/forum/' + slug(forum) + '/question/' + slug(question) + '/reopen'"/>
                            <t t-set="label" t-value="'Reopen'"/>
                            <t t-set="classes" t-value="'fa-arrow-right'"/>
                            <t t-set="karma" t-value="not question.can_close and question.karma_close or 0"/>
                        </t>

                <t t-raw="question.content"/>

                            <t t-foreach="question.tag_ids" t-as="tag">

                            </t>

                                    Comment

                                <t t-call="website_forum.link_button">
                                    <t t-set="url" t-value="'/forum/' + slug(forum) +'/question/' + slug(question) + '/ask_for_close'"/>
                                    <t t-set="label" t-value="'Close'"/>
                                    <t t-set="classes" t-value="'fa-times'"/>
                                    <t t-set="karma" t-value="not question.can_close and question.karma_close or 0"/>
                                </t>

                                <t t-call="website_forum.link_button">
                                    <t t-set="url" t-value="'/forum/' + slug(forum) +'/question/' + slug(question) + '/reopen'"/>
                                    <t t-set="label" t-value="'Reopen'"/>
                                    <t t-set="classes" t-value="'fa-undo'"/>
                                    <t t-set="karma" t-value="not question.can_close and question.karma_close or 0"/>
                                </t>

                                <t t-call="website_forum.link_button">
                                    <t t-set="url" t-value="'/forum/' + slug(forum) +'/post/' + slug(question) + '/edit'"/>
                                    <t t-set="label" t-value="'Edit'"/>
                                    <t t-set="classes" t-value="'fa-edit'"/>
                                    <t t-set="karma" t-value="not question.can_edit and question.karma_edit or 0"/>
                                </t>

                                <t t-call="website_forum.link_button">
                                    <t t-set="url" t-value="'/forum/' + slug(forum) +'/question/' + slug(question) + '/delete'"/>
                                    <t t-set="label" t-value="'Delete'"/>
                                    <t t-set="classes" t-value="'fa-trash-o'"/>
                                    <t t-set="karma" t-value="not question.can_unlink and question.karma_unlink or 0"/>
                                </t>

                                <t t-call="website_forum.link_button">
                                    <t t-set="url" t-value="'/forum/' + slug(forum) +'/question/' + slug(question) + '/undelete'"/>
                                    <t t-set="label" t-value="'Undelete'"/>
                                    <t t-set="classes" t-value="'fa-trash-o'"/>
                                    <t t-set="karma" t-value="not question.can_unlink and question.karma_unlink or 0"/>
                                </t>

                            Asked on

                        <t t-call="website_forum.vote">
                            <t t-set="post" t-value="question"/>
                        </t>

                             Views

                <t t-call="website_forum.post_comment">
                    <t t-set="object" t-value="question"/>
                </t>

                    <t t-call="website_forum.vote">
                        <t t-set="post" t-value="answer"/>
                    </t>

                    <t t-raw="answer.content"/>

                                 Comment

                                <t t-call="website_forum.link_button">
                                    <t t-set="url" t-value="'/forum/' + slug(forum) + '/post/' + slug(answer) + '/edit'"/>
                                    <t t-set="label" t-value="'Edit'"/>
                                    <t t-set="classes" t-value="'fa fa-edit'"/>
                                    <t t-set="karma" t-value="not answer.can_edit and answer.karma_edit or 0"/>
                                </t>

                                <t t-call="website_forum.link_button">
                                    <t t-set="url" t-value="'/forum/' + slug(forum) + '/post/' + slug(answer) + '/delete'"/>
                                    <t t-set="label" t-value="'Delete'"/>
                                    <t t-set="classes" t-value="'fa-trash-o'"/>
                                    <t t-set="karma" t-value="not answer.can_unlink and answer.karma_unlink or 0"/>
                                </t>

                                <t t-call="website_forum.link_button">
                                    <t t-set="url" t-value="'/forum/' + slug(forum) + '/post/' + slug(answer) + '/convert_to_comment'"/>
                                    <t t-set="label" t-value="'Convert as a comment'"/>
                                    <t t-set="classes" t-value="'fa-magic'"/>
                                    <t t-set="karma" t-value="not answer.can_comment_convert and answer.karma_comment_convert or 0"/>
                                </t>

                            Answered on

                            <t t-call="website_forum.vote">
                                <t t-set="post" t-value="answer"/>
                            </t>

                    <t t-call="website_forum.post_comment">
                        <t t-set="object" t-value="answer"/>
                    </t>

            <t t-call="website_forum.post_answer"/>

            Edit Your Previous Answer
            (only one answer per question is allowed)

    </t>
</template>

<template id="post_comment">

                    <t t-set="required_karma" t-value="message.author_id.id == user.partner_id.id and object.forum_id.karma_comment_unlink_own or object.forum_id.karma_comment_unlink_all"/>
                    <t t-call="website_forum.link_button">
                        <t t-set="url" t-value="'/forum/' + slug(forum) + '/post/' + slug(object) + '/comment/' + slug(message) + '/delete'"/>
                        <t t-set="label" t-value="' '"/>
                        <t t-set="karma" t-value="user.karma<required_karma and required_karma or 0"/>
                        <t t-set="classes" t-value="'close comment_delete fa-times'"/>
                    </t>

                    <t t-set="required_karma" t-value="message.author_id.id == user.partner_id.id and object.forum_id.karma_comment_convert_own or object.forum_id.karma_comment_convert_all"/>
                    <t t-call="website_forum.link_button">
                        <t t-set="url" t-value="'/forum/' + slug(forum) + '/post/' + slug(object) + '/comment/' + slug(message) + '/convert_to_answer'"/>
                        <t t-set="label" t-value="'Convert as an answer'"/>
                        <t t-set="karma" t-value="user.karma<required_karma and required_karma or 0"/>
                        <t t-set="classes" t-value="'fa-magic pull-right'"/>
                    </t>

                    on

                <form t-attf-id="comment#{ object._name.replace('.','') + '-' + str(object.id) }" class="collapse oe_comment_grey"
                        t-attf-action="/forum/#{slug(forum)}/post/#{slug(object)}/comment" method="POST">
                    <input name="post_id" t-att-value="object.id" type="hidden" class="mt8"/>
                    <textarea name="comment" class="form-control" placeholder="Comment this post..."/>
                    <button type="submit" class="btn btn-primary mt8">Post</button>
                </form>

</template>

<template id="tag">
    <t t-call="website_forum.header">

            Tags

            A tag is a label that categorizes your question with other,
            similar questions. Using the right tags makes it easier for
            others to find and answer your question.

                    X <t t-esc="tag.posts_count"/>

    </t>
</template>

<template id="badge">
    <t t-call="website_forum.header">

            Badges

            Besides gaining reputation with your questions and answers,
            you receive badges for being especially helpful. Badges
            appear on your profile page, and your posts.

                    awarded users

    </t>
</template>

<template id="badge_user">
    <t t-call="website_forum.header">

            Badge ""

            <t class="pull-left" t-esc="badge.stat_count_distinct"/>
            users
            user
            received this badge:

    </t>
</template>

<template id="users">
    <t t-call="website_forum.header">

                    <t t-if="user.country_id">

                    </t>
                    <t t-esc="user.karma"/>
                    <t t-raw="separator"/>

                         badges:

                        <t t-esc="user.gold_badge"/>

                        <t t-esc="user.silver_badge"/>

                        <t t-esc="user.bronze_badge"/>

                    <t t-raw="0"/>

            <t t-call="website.pager"/>

    </t>
</template>

<template id="private_profile">
    <t t-call="website_forum.header">

This profile is private!

            Return to the question list.

    </t>
</template>

<template id="edit_profile">
    <t t-call="website_forum.header">

Edit Profile

            <form t-attf-action="/forum/#{slug(forum)}/user/#{slug(user)}/save" method="post" role="form" class="form-horizontal">
                <input name="user_id" t-att-value="user.id" type="hidden"/>

                    Real name

                        <input type="text" class="form-control" name="name" id="user_name" required="True" t-attf-value="#{user.name}"/>

                    Public profile

                        <input type="checkbox" class="mt8" name="website_published" id="user_website_published" value="True" t-if="not user.website_published"/>
                        <input type="checkbox" class="mt8" name="website_published" id="user_website_published" value="True" checked="checked" t-if="user.website_published"/>

                    Website

                        <input type="text" class="form-control" name="website" id="user_website" t-attf-value="#{user.partner_id.website or ''}"/>

                        <button type="button" class="close" data-dismiss="alert">x</button>

Please enter a valid email address in order to receive notifications from answers or comments.

                    Email

                        <input type="text" class="form-control" name="email" id="user_email" required="True" t-attf-value="#{user.partner_id.email}"/>

                    City

                        <input type="text" class="form-control" name="city" id="user_city" t-attf-value="#{user.partner_id.city or ''}"/>

                    Country

                        <select class="form-control" name="country">
                            <option value="">Country...</option>
                            <t t-foreach="countries or []" t-as="country">
                                <option t-att-value="country.id" t-att-selected="country.id == user.partner_id.country_id.id"><t t-esc="country.name"/></option>
                            </t>
                         </select>

                    Biography

                        <textarea name="description" id="description" style="min-height: 120px" required="True"
                            class="form-control load_editor"><t t-esc="user.partner_id.website_description"/></textarea>

                    <button class="btn btn-primary btn-lg">Update</button>

            </form>

    </t>
</template>

<template id="user_detail_full">
    <t t-call="website_forum.header">

            profile
            <t t-call="website.publish_management" groups="base.group_website_publisher">
                <t t-set="object" t-value="user"/>
            </t>

                    contributions
                    member since

                    last connection

                    bio
                    website

                    location

                        ,

                        <t t-if="user.country_id"> </t>

                    stats
                    karma

                    votes

                    <t t-if="uid == user.id">
                         Edit Your Bio
                    </t>

                <t t-esc="count_questions"/> Questions

                <t t-esc="count_answers"/> Answers

                <t t-esc="len(favourite)"/> Favourite Questions

                <t t-esc="len(followed)"/> Followed Questions

                Activity

                Badges

                Votes

                    <t t-call="website_forum.display_post"/>

                    <t t-call="website_forum.display_post_answer"/>

Karma

                <t t-call="website_forum.user_badges"/>

                    <t t-call="website_forum.display_post"/>

                    <t t-call="website_forum.display_post"/>

                <t t-call="website_forum.user_votes"/>

                        <t t-set="post" t-value="posts[activity.res_id]"/>

    </t>
</template>

<template id="user_badges">

                awarded users

        No badge yet!

         Check available badges

</template>

<template id="user_votes">

        <t t-esc="vote.post_id.create_date"/>

        <t t-if="vote.post_id.parent_id">

        </t>
        <t t-if="not vote.post_id.parent_id">

        </t>

        No vote given by you yet!

</template>

<template id="content_new_forum" inherit_id="website.user_navbar" groups="base.group_user">
    <xpath expr="//ul[@id='oe_systray']/li/ul[@class='dropdown-menu oe_content_menu']" position="inside">

New Forum

    </xpath>
</template>

    </data>
</openerp>


text:
// Details for templated Spreadsort-based float_sort.

//          Copyright Steven J. Ross 2001 - 2014.
// Distributed under the Boost Software License, Version 1.0.
//    (See accompanying file LICENSE_1_0.txt or copy at
//          http://www.boost.org/LICENSE_1_0.txt)

// See http://www.boost.org/libs/sort for library home page.

/*
Some improvements suggested by:
Phil Endecott and Frank Gennari
float_mem_cast fix provided by:
Scott McMurray
*/

#ifndef BOOST_SORT_SPREADSORT_DETAIL_FLOAT_SORT_HPP
#define BOOST_SORT_SPREADSORT_DETAIL_FLOAT_SORT_HPP
#include <algorithm>
#include <vector>
#include <limits>
#include <functional>
#include <boost/static_assert.hpp>
#include <boost/serialization/static_warning.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/sort/spreadsort/detail/constants.hpp>
#include <boost/sort/spreadsort/detail/integer_sort.hpp>
#include <boost/sort/spreadsort/detail/spreadsort_common.hpp>
#include <boost/cstdint.hpp>

namespace boost {
namespace sort {
namespace spreadsort {
  namespace detail {
    //Casts a RandomAccessIter to the specified integer type
    template<class Cast_type, class RandomAccessIter>
    inline Cast_type
    cast_float_iter(const RandomAccessIter & floatiter)
    {
      typedef typename std::iterator_traits<RandomAccessIter>::value_type
        Data_type;
      //Only cast IEEE floating-point numbers, and only to same-sized integers
      BOOST_STATIC_ASSERT(sizeof(Cast_type) == sizeof(Data_type));
      BOOST_STATIC_ASSERT(std::numeric_limits<Data_type>::is_iec559);
      BOOST_STATIC_ASSERT(std::numeric_limits<Cast_type>::is_integer);
      Cast_type result;
      std::memcpy(&result, &(*floatiter), sizeof(Data_type));
      return result;
    }

    // Return true if the list is sorted.  Otherwise, find the minimum and
    // maximum.  Values are Right_shifted 0 bits before comparison.
    template <class RandomAccessIter, class Div_type, class Right_shift>
    inline bool
    is_sorted_or_find_extremes(RandomAccessIter current, RandomAccessIter last,
                  Div_type & max, Div_type & min, Right_shift rshift)
    {
      min = max = rshift(*current, 0);
      RandomAccessIter prev = current;
      bool sorted = true;
      while (++current < last) {
        Div_type value = rshift(*current, 0);
        sorted &= *current >= *prev;
        prev = current;
        if (max < value)
          max = value;
        else if (value < min)
          min = value;
      }
      return sorted;
    }

    // Return true if the list is sorted.  Otherwise, find the minimum and
    // maximum.  Uses comp to check if the data is already sorted.
    template <class RandomAccessIter, class Div_type, class Right_shift,
              class Compare>
    inline bool
    is_sorted_or_find_extremes(RandomAccessIter current, RandomAccessIter last,
                               Div_type & max, Div_type & min,
                               Right_shift rshift, Compare comp)
    {
      min = max = rshift(*current, 0);
      RandomAccessIter prev = current;
      bool sorted = true;
      while (++current < last) {
        Div_type value = rshift(*current, 0);
        sorted &= !comp(*current, *prev);
        prev = current;
        if (max < value)
          max = value;
        else if (value < min)
          min = value;
      }
      return sorted;
    }

    //Specialized swap loops for floating-point casting
    template <class RandomAccessIter, class Div_type>
    inline void inner_float_swap_loop(RandomAccessIter * bins,
                        const RandomAccessIter & nextbinstart, unsigned ii
                        , const unsigned log_divisor, const Div_type div_min)
    {
      RandomAccessIter * local_bin = bins + ii;
      for (RandomAccessIter current = *local_bin; current < nextbinstart;
          ++current) {
        for (RandomAccessIter * target_bin =
            (bins + ((cast_float_iter<Div_type, RandomAccessIter>(current) >>
                      log_divisor) - div_min));  target_bin != local_bin;
          target_bin = bins + ((cast_float_iter<Div_type, RandomAccessIter>
                               (current) >> log_divisor) - div_min)) {
          typename std::iterator_traits<RandomAccessIter>::value_type tmp;
          RandomAccessIter b = (*target_bin)++;
          RandomAccessIter * b_bin = bins + ((cast_float_iter<Div_type,
                              RandomAccessIter>(b) >> log_divisor) - div_min);
          //Three-way swap; if the item to be swapped doesn't belong in the
          //current bin, swap it to where it belongs
          if (b_bin != local_bin) {
            RandomAccessIter c = (*b_bin)++;
            tmp = *c;
            *c = *b;
          }
          else
            tmp = *b;
          *b = *current;
          *current = tmp;
        }
      }
      *local_bin = nextbinstart;
    }

    template <class RandomAccessIter, class Div_type>
    inline void float_swap_loop(RandomAccessIter * bins,
                          RandomAccessIter & nextbinstart, unsigned ii,
                          const size_t *bin_sizes,
                          const unsigned log_divisor, const Div_type div_min)
    {
      nextbinstart += bin_sizes[ii];
      inner_float_swap_loop<RandomAccessIter, Div_type>
        (bins, nextbinstart, ii, log_divisor, div_min);
    }

    // Return true if the list is sorted.  Otherwise, find the minimum and
    // maximum.  Values are cast to Cast_type before comparison.
    template <class RandomAccessIter, class Cast_type>
    inline bool
    is_sorted_or_find_extremes(RandomAccessIter current, RandomAccessIter last,
                  Cast_type & max, Cast_type & min)
    {
      min = max = cast_float_iter<Cast_type, RandomAccessIter>(current);
      RandomAccessIter prev = current;
      bool sorted = true;
      while (++current < last) {
        Cast_type value = cast_float_iter<Cast_type, RandomAccessIter>(current);
        sorted &= *current >= *prev;
        prev = current;
        if (max < value)
          max = value;
        else if (value < min)
          min = value;
      }
      return sorted;
    }

    //Special-case sorting of positive floats with casting
    template <class RandomAccessIter, class Div_type, class Size_type>
    inline void
    positive_float_sort_rec(RandomAccessIter first, RandomAccessIter last,
              std::vector<RandomAccessIter> &bin_cache, unsigned cache_offset
              , size_t *bin_sizes)
    {
      Div_type max, min;
      if (is_sorted_or_find_extremes<RandomAccessIter, Div_type>(first, last,
                                                                max, min))
        return;
      unsigned log_divisor = get_log_divisor<float_log_mean_bin_size>(
          last - first, rough_log_2_size(Size_type(max - min)));
      Div_type div_min = min >> log_divisor;
      Div_type div_max = max >> log_divisor;
      unsigned bin_count = unsigned(div_max - div_min) + 1;
      unsigned cache_end;
      RandomAccessIter * bins = size_bins(bin_sizes, bin_cache, cache_offset,
                                          cache_end, bin_count);

      //Calculating the size of each bin
      for (RandomAccessIter current = first; current != last;)
        bin_sizes[unsigned((cast_float_iter<Div_type, RandomAccessIter>(
            current++) >> log_divisor) - div_min)]++;
      bins[0] = first;
      for (unsigned u = 0; u < bin_count - 1; u++)
        bins[u + 1] = bins[u] + bin_sizes[u];

      //Swap into place
      RandomAccessIter nextbinstart = first;
      for (unsigned u = 0; u < bin_count - 1; ++u)
        float_swap_loop<RandomAccessIter, Div_type>
          (bins, nextbinstart, u, bin_sizes, log_divisor, div_min);
      bins[bin_count - 1] = last;

      //Return if we've completed bucketsorting
      if (!log_divisor)
        return;

      //Recursing
      size_t max_count = get_min_count<float_log_mean_bin_size,
                                       float_log_min_split_count,
                                       float_log_finishing_count>(log_divisor);
      RandomAccessIter lastPos = first;
      for (unsigned u = cache_offset; u < cache_end; lastPos = bin_cache[u],
          ++u) {
        size_t count = bin_cache[u] - lastPos;
        if (count < 2)
          continue;
        if (count < max_count)
          std::sort(lastPos, bin_cache[u]);
        else
          positive_float_sort_rec<RandomAccessIter, Div_type, Size_type>
            (lastPos, bin_cache[u], bin_cache, cache_end, bin_sizes);
      }
    }

    //Sorting negative floats
    //Bins are iterated in reverse because max_neg_float = min_neg_int
    template <class RandomAccessIter, class Div_type, class Size_type>
    inline void
    negative_float_sort_rec(RandomAccessIter first, RandomAccessIter last,
                        std::vector<RandomAccessIter> &bin_cache,
                        unsigned cache_offset, size_t *bin_sizes)
    {
      Div_type max, min;
      if (is_sorted_or_find_extremes<RandomAccessIter, Div_type>(first, last,
                                                                 max, min))
        return;

      unsigned log_divisor = get_log_divisor<float_log_mean_bin_size>(
          last - first, rough_log_2_size(Size_type(max - min)));
      Div_type div_min = min >> log_divisor;
      Div_type div_max = max >> log_divisor;
      unsigned bin_count = unsigned(div_max - div_min) + 1;
      unsigned cache_end;
      RandomAccessIter * bins = size_bins(bin_sizes, bin_cache, cache_offset,
                                          cache_end, bin_count);

      //Calculating the size of each bin
      for (RandomAccessIter current = first; current != last;)
        bin_sizes[unsigned((cast_float_iter<Div_type, RandomAccessIter>(
            current++) >> log_divisor) - div_min)]++;
      bins[bin_count - 1] = first;
      for (int ii = bin_count - 2; ii >= 0; --ii)
        bins[ii] = bins[ii + 1] + bin_sizes[ii + 1];

      //Swap into place
      RandomAccessIter nextbinstart = first;
      //The last bin will always have the correct elements in it
      for (int ii = bin_count - 1; ii > 0; --ii)
        float_swap_loop<RandomAccessIter, Div_type>
          (bins, nextbinstart, ii, bin_sizes, log_divisor, div_min);
      //Update the end position because we don't process the last bin
      bin_cache[cache_offset] = last;

      //Return if we've completed bucketsorting
      if (!log_divisor)
        return;

      //Recursing
      size_t max_count = get_min_count<float_log_mean_bin_size,
                                       float_log_min_split_count,
                                       float_log_finishing_count>(log_divisor);
      RandomAccessIter lastPos = first;
      for (int ii = cache_end - 1; ii >= static_cast<int>(cache_offset);
          lastPos = bin_cache[ii], --ii) {
        size_t count = bin_cache[ii] - lastPos;
        if (count < 2)
          continue;
        if (count < max_count)
          std::sort(lastPos, bin_cache[ii]);
        else
          negative_float_sort_rec<RandomAccessIter, Div_type, Size_type>
            (lastPos, bin_cache[ii], bin_cache, cache_end, bin_sizes);
      }
    }

    //Sorting negative floats
    //Bins are iterated in reverse order because max_neg_float = min_neg_int
    template <class RandomAccessIter, class Div_type, class Right_shift,
              class Size_type>
    inline void
    negative_float_sort_rec(RandomAccessIter first, RandomAccessIter last,
              std::vector<RandomAccessIter> &bin_cache, unsigned cache_offset
              , size_t *bin_sizes, Right_shift rshift)
    {
      Div_type max, min;
      if (is_sorted_or_find_extremes(first, last, max, min, rshift))
        return;
      unsigned log_divisor = get_log_divisor<float_log_mean_bin_size>(
          last - first, rough_log_2_size(Size_type(max - min)));
      Div_type div_min = min >> log_divisor;
      Div_type div_max = max >> log_divisor;
      unsigned bin_count = unsigned(div_max - div_min) + 1;
      unsigned cache_end;
      RandomAccessIter * bins = size_bins(bin_sizes, bin_cache, cache_offset,
                                          cache_end, bin_count);

      //Calculating the size of each bin
      for (RandomAccessIter current = first; current != last;)
        bin_sizes[unsigned(rshift(*(current++), log_divisor) - div_min)]++;
      bins[bin_count - 1] = first;
      for (int ii = bin_count - 2; ii >= 0; --ii)
        bins[ii] = bins[ii + 1] + bin_sizes[ii + 1];

      //Swap into place
      RandomAccessIter nextbinstart = first;
      //The last bin will always have the correct elements in it
      for (int ii = bin_count - 1; ii > 0; --ii)
        swap_loop<RandomAccessIter, Div_type, Right_shift>
          (bins, nextbinstart, ii, rshift, bin_sizes, log_divisor, div_min);
      //Update the end position of the unprocessed last bin
      bin_cache[cache_offset] = last;

      //Return if we've completed bucketsorting
      if (!log_divisor)
        return;

      //Recursing
      size_t max_count = get_min_count<float_log_mean_bin_size,
                                       float_log_min_split_count,
                                       float_log_finishing_count>(log_divisor);
      RandomAccessIter lastPos = first;
      for (int ii = cache_end - 1; ii >= static_cast<int>(cache_offset);
          lastPos = bin_cache[ii], --ii) {
        size_t count = bin_cache[ii] - lastPos;
        if (count < 2)
          continue;
        if (count < max_count)
          std::sort(lastPos, bin_cache[ii]);
        else
          negative_float_sort_rec<RandomAccessIter, Div_type, Right_shift,
                                  Size_type>
            (lastPos, bin_cache[ii], bin_cache, cache_end, bin_sizes, rshift);
      }
    }

    template <class RandomAccessIter, class Div_type, class Right_shift,
              class Compare, class Size_type>
    inline void
    negative_float_sort_rec(RandomAccessIter first, RandomAccessIter last,
            std::vector<RandomAccessIter> &bin_cache, unsigned cache_offset,
            size_t *bin_sizes, Right_shift rshift, Compare comp)
    {
      Div_type max, min;
      if (is_sorted_or_find_extremes(first, last, max, min, rshift, comp))
        return;
      unsigned log_divisor = get_log_divisor<float_log_mean_bin_size>(
          last - first, rough_log_2_size(Size_type(max - min)));
      Div_type div_min = min >> log_divisor;
      Div_type div_max = max >> log_divisor;
      unsigned bin_count = unsigned(div_max - div_min) + 1;
      unsigned cache_end;
      RandomAccessIter * bins = size_bins(bin_sizes, bin_cache, cache_offset,
                                          cache_end, bin_count);

      //Calculating the size of each bin
      for (RandomAccessIter current = first; current != last;)
        bin_sizes[unsigned(rshift(*(current++), log_divisor) - div_min)]++;
      bins[bin_count - 1] = first;
      for (int ii = bin_count - 2; ii >= 0; --ii)
        bins[ii] = bins[ii + 1] + bin_sizes[ii + 1];

      //Swap into place
      RandomAccessIter nextbinstart = first;
      //The last bin will always have the correct elements in it
      for (int ii = bin_count - 1; ii > 0; --ii)
        swap_loop<RandomAccessIter, Div_type, Right_shift>
          (bins, nextbinstart, ii, rshift, bin_sizes, log_divisor, div_min);
      //Update the end position of the unprocessed last bin
      bin_cache[cache_offset] = last;

      //Return if we've completed bucketsorting
      if (!log_divisor)
        return;

      //Recursing
      size_t max_count = get_min_count<float_log_mean_bin_size,
                                       float_log_min_split_count,
                                       float_log_finishing_count>(log_divisor);
      RandomAccessIter lastPos = first;
      for (int ii = cache_end - 1; ii >= static_cast<int>(cache_offset);
          lastPos = bin_cache[ii], --ii) {
        size_t count = bin_cache[ii] - lastPos;
        if (count < 2)
          continue;
        if (count < max_count)
          std::sort(lastPos, bin_cache[ii], comp);
        else
          negative_float_sort_rec<RandomAccessIter, Div_type, Right_shift,
                                  Compare, Size_type>(lastPos, bin_cache[ii],
                                                      bin_cache, cache_end,
                                                      bin_sizes, rshift, comp);
      }
    }

    //Casting special-case for floating-point sorting
    template <class RandomAccessIter, class Div_type, class Size_type>
    inline void
    float_sort_rec(RandomAccessIter first, RandomAccessIter last,
                std::vector<RandomAccessIter> &bin_cache, unsigned cache_offset
                , size_t *bin_sizes)
    {
      Div_type max, min;
      if (is_sorted_or_find_extremes<RandomAccessIter, Div_type>(first, last,
                                                                max, min))
        return;
      unsigned log_divisor = get_log_divisor<float_log_mean_bin_size>(
          last - first, rough_log_2_size(Size_type(max - min)));
      Div_type div_min = min >> log_divisor;
      Div_type div_max = max >> log_divisor;
      unsigned bin_count = unsigned(div_max - div_min) + 1;
      unsigned cache_end;
      RandomAccessIter * bins = size_bins(bin_sizes, bin_cache, cache_offset,
                                          cache_end, bin_count);

      //Calculating the size of each bin
      for (RandomAccessIter current = first; current != last;)
        bin_sizes[unsigned((cast_float_iter<Div_type, RandomAccessIter>(
            current++) >> log_divisor) - div_min)]++;
      //The index of the first positive bin
      //Must be divided small enough to fit into an integer
      unsigned first_positive = (div_min < 0) ? unsigned(-div_min) : 0;
      //Resetting if all bins are negative
      if (cache_offset + first_positive > cache_end)
        first_positive = cache_end - cache_offset;
      //Reversing the order of the negative bins
      //Note that because of the negative/positive ordering direction flip
      //We can not depend upon bin order and positions matching up
      //so bin_sizes must be reused to contain the end of the bin
      if (first_positive > 0) {
        bins[first_positive - 1] = first;
        for (int ii = first_positive - 2; ii >= 0; --ii) {
          bins[ii] = first + bin_sizes[ii + 1];
          bin_sizes[ii] += bin_sizes[ii + 1];
        }
        //Handling positives following negatives
        if (first_positive < bin_count) {
          bins[first_positive] = first + bin_sizes[0];
          bin_sizes[first_positive] += bin_sizes[0];
        }
      }
      else
        bins[0] = first;
      for (unsigned u = first_positive; u < bin_count - 1; u++) {
        bins[u + 1] = first + bin_sizes[u];
        bin_sizes[u + 1] += bin_sizes[u];
      }

      //Swap into place
      RandomAccessIter nextbinstart = first;
      for (unsigned u = 0; u < bin_count; ++u) {
        nextbinstart = first + bin_sizes[u];
        inner_float_swap_loop<RandomAccessIter, Div_type>
          (bins, nextbinstart, u, log_divisor, div_min);
      }

      if (!log_divisor)
        return;

      //Handling negative values first
      size_t max_count = get_min_count<float_log_mean_bin_size,
                                       float_log_min_split_count,
                                       float_log_finishing_count>(log_divisor);
      RandomAccessIter lastPos = first;
      for (int ii = cache_offset + first_positive - 1;
           ii >= static_cast<int>(cache_offset);
           lastPos = bin_cache[ii--]) {
        size_t count = bin_cache[ii] - lastPos;
        if (count < 2)
          continue;
        if (count < max_count)
          std::sort(lastPos, bin_cache[ii]);
        //sort negative values using reversed-bin spreadsort
        else
          negative_float_sort_rec<RandomAccessIter, Div_type, Size_type>
            (lastPos, bin_cache[ii], bin_cache, cache_end, bin_sizes);
      }

      for (unsigned u = cache_offset + first_positive; u < cache_end;
          lastPos = bin_cache[u], ++u) {
        size_t count = bin_cache[u] - lastPos;
        if (count < 2)
          continue;
        if (count < max_count)
          std::sort(lastPos, bin_cache[u]);
        //sort positive values using normal spreadsort
        else
          positive_float_sort_rec<RandomAccessIter, Div_type, Size_type>
            (lastPos, bin_cache[u], bin_cache, cache_end, bin_sizes);
      }
    }

    //Functor implementation for recursive sorting
    template <class RandomAccessIter, class Div_type, class Right_shift
      , class Size_type>
    inline void
    float_sort_rec(RandomAccessIter first, RandomAccessIter last,
              std::vector<RandomAccessIter> &bin_cache, unsigned cache_offset
              , size_t *bin_sizes, Right_shift rshift)
    {
      Div_type max, min;
      if (is_sorted_or_find_extremes(first, last, max, min, rshift))
        return;
      unsigned log_divisor = get_log_divisor<float_log_mean_bin_size>(
          last - first, rough_log_2_size(Size_type(max - min)));
      Div_type div_min = min >> log_divisor;
      Div_type div_max = max >> log_divisor;
      unsigned bin_count = unsigned(div_max - div_min) + 1;
      unsigned cache_end;
      RandomAccessIter * bins = size_bins(bin_sizes, bin_cache, cache_offset,
                                          cache_end, bin_count);

      //Calculating the size of each bin
      for (RandomAccessIter current = first; current != last;)
        bin_sizes[unsigned(rshift(*(current++), log_divisor) - div_min)]++;
      //The index of the first positive bin
      unsigned first_positive = (div_min < 0) ? unsigned(-div_min) : 0;
      //Resetting if all bins are negative
      if (cache_offset + first_positive > cache_end)
        first_positive = cache_end - cache_offset;
      //Reversing the order of the negative bins
      //Note that because of the negative/positive ordering direction flip
      //We can not depend upon bin order and positions matching up
      //so bin_sizes must be reused to contain the end of the bin
      if (first_positive > 0) {
        bins[first_positive - 1] = first;
        for (int ii = first_positive - 2; ii >= 0; --ii) {
          bins[ii] = first + bin_sizes[ii + 1];
          bin_sizes[ii] += bin_sizes[ii + 1];
        }
        //Handling positives following negatives
        if (static_cast<unsigned>(first_positive) < bin_count) {
          bins[first_positive] = first + bin_sizes[0];
          bin_sizes[first_positive] += bin_sizes[0];
        }
      }
      else
        bins[0] = first;
      for (unsigned u = first_positive; u < bin_count - 1; u++) {
        bins[u + 1] = first + bin_sizes[u];
        bin_sizes[u + 1] += bin_sizes[u];
      }

      //Swap into place
      RandomAccessIter next_bin_start = first;
      for (unsigned u = 0; u < bin_count; ++u) {
        next_bin_start = first + bin_sizes[u];
        inner_swap_loop<RandomAccessIter, Div_type, Right_shift>
          (bins, next_bin_start, u, rshift, log_divisor, div_min);
      }

      //Return if we've completed bucketsorting
      if (!log_divisor)
        return;

      //Handling negative values first
      size_t max_count = get_min_count<float_log_mean_bin_size,
                                       float_log_min_split_count,
                                       float_log_finishing_count>(log_divisor);
      RandomAccessIter lastPos = first;
      for (int ii = cache_offset + first_positive - 1;
           ii >= static_cast<int>(cache_offset);
           lastPos = bin_cache[ii--]) {
        size_t count = bin_cache[ii] - lastPos;
        if (count < 2)
          continue;
        if (count < max_count)
          std::sort(lastPos, bin_cache[ii]);
        //sort negative values using reversed-bin spreadsort
        else
          negative_float_sort_rec<RandomAccessIter, Div_type,
            Right_shift, Size_type>(lastPos, bin_cache[ii], bin_cache,
                                    cache_end, bin_sizes, rshift);
      }

      for (unsigned u = cache_offset + first_positive; u < cache_end;
          lastPos = bin_cache[u], ++u) {
        size_t count = bin_cache[u] - lastPos;
        if (count < 2)
          continue;
        if (count < max_count)
          std::sort(lastPos, bin_cache[u]);
        //sort positive values using normal spreadsort
        else
          spreadsort_rec<RandomAccessIter, Div_type, Right_shift, Size_type,
                          float_log_mean_bin_size, float_log_min_split_count,
                          float_log_finishing_count>
            (lastPos, bin_cache[u], bin_cache, cache_end, bin_sizes, rshift);
      }
    }

    template <class RandomAccessIter, class Div_type, class Right_shift,
              class Compare, class Size_type>
    inline void
    float_sort_rec(RandomAccessIter first, RandomAccessIter last,
            std::vector<RandomAccessIter> &bin_cache, unsigned cache_offset,
            size_t *bin_sizes, Right_shift rshift, Compare comp)
    {
      Div_type max, min;
      if (is_sorted_or_find_extremes(first, last, max, min, rshift, comp))
        return;
      unsigned log_divisor = get_log_divisor<float_log_mean_bin_size>(
          last - first, rough_log_2_size(Size_type(max - min)));
      Div_type div_min = min >> log_divisor;
      Div_type div_max = max >> log_divisor;
      unsigned bin_count = unsigned(div_max - div_min) + 1;
      unsigned cache_end;
      RandomAccessIter * bins = size_bins(bin_sizes, bin_cache, cache_offset,
                                          cache_end, bin_count);

      //Calculating the size of each bin
      for (RandomAccessIter current = first; current != last;)
        bin_sizes[unsigned(rshift(*(current++), log_divisor) - div_min)]++;
      //The index of the first positive bin
      unsigned first_positive =
        (div_min < 0) ? static_cast<unsigned>(-div_min) : 0;
      //Resetting if all bins are negative
      if (cache_offset + first_positive > cache_end)
        first_positive = cache_end - cache_offset;
      //Reversing the order of the negative bins
      //Note that because of the negative/positive ordering direction flip
      //We can not depend upon bin order and positions matching up
      //so bin_sizes must be reused to contain the end of the bin
      if (first_positive > 0) {
        bins[first_positive - 1] = first;
        for (int ii = first_positive - 2; ii >= 0; --ii) {
          bins[ii] = first + bin_sizes[ii + 1];
          bin_sizes[ii] += bin_sizes[ii + 1];
        }
        //Handling positives following negatives
        if (static_cast<unsigned>(first_positive) < bin_count) {
          bins[first_positive] = first + bin_sizes[0];
          bin_sizes[first_positive] += bin_sizes[0];
        }
      }
      else
        bins[0] = first;
      for (unsigned u = first_positive; u < bin_count - 1; u++) {
        bins[u + 1] = first + bin_sizes[u];
        bin_sizes[u + 1] += bin_sizes[u];
      }

      //Swap into place
      RandomAccessIter next_bin_start = first;
      for (unsigned u = 0; u < bin_count; ++u) {
        next_bin_start = first + bin_sizes[u];
        inner_swap_loop<RandomAccessIter, Div_type, Right_shift>
          (bins, next_bin_start, u, rshift, log_divisor, div_min);
      }

      //Return if we've completed bucketsorting
      if (!log_divisor)
        return;

      //Handling negative values first
      size_t max_count = get_min_count<float_log_mean_bin_size,
                                       float_log_min_split_count,
                                       float_log_finishing_count>(log_divisor);
      RandomAccessIter lastPos = first;
      for (int ii = cache_offset + first_positive - 1;
           ii >= static_cast<int>(cache_offset);
           lastPos = bin_cache[ii--]) {
        size_t count = bin_cache[ii] - lastPos;
        if (count < 2)
          continue;
        if (count < max_count)
          std::sort(lastPos, bin_cache[ii], comp);
        //sort negative values using reversed-bin spreadsort
        else
          negative_float_sort_rec<RandomAccessIter, Div_type, Right_shift,
                                  Compare, Size_type>(lastPos, bin_cache[ii],
                                                      bin_cache, cache_end,
                                                      bin_sizes, rshift, comp);
      }

      for (unsigned u = cache_offset + first_positive; u < cache_end;
          lastPos = bin_cache[u], ++u) {
        size_t count = bin_cache[u] - lastPos;
        if (count < 2)
          continue;
        if (count < max_count)
          std::sort(lastPos, bin_cache[u], comp);
        //sort positive values using normal spreadsort
        else
          spreadsort_rec<RandomAccessIter, Div_type, Right_shift, Compare,
                          Size_type, float_log_mean_bin_size,
                          float_log_min_split_count, float_log_finishing_count>
      (lastPos, bin_cache[u], bin_cache, cache_end, bin_sizes, rshift, comp);
      }
    }

    //Checking whether the value type is a float, and trying a 32-bit integer
    template <class RandomAccessIter>
    inline typename boost::enable_if_c< sizeof(boost::uint32_t) ==
      sizeof(typename std::iterator_traits<RandomAccessIter>::value_type)
      && std::numeric_limits<typename
      std::iterator_traits<RandomAccessIter>::value_type>::is_iec559,
      void >::type
    float_sort(RandomAccessIter first, RandomAccessIter last)
    {
      size_t bin_sizes[1 << max_finishing_splits];
      std::vector<RandomAccessIter> bin_cache;
      float_sort_rec<RandomAccessIter, boost::int32_t, boost::uint32_t>
        (first, last, bin_cache, 0, bin_sizes);
    }

    //Checking whether the value type is a double, and using a 64-bit integer
    template <class RandomAccessIter>
    inline typename boost::enable_if_c< sizeof(boost::uint64_t) ==
      sizeof(typename std::iterator_traits<RandomAccessIter>::value_type)
      && std::numeric_limits<typename
      std::iterator_traits<RandomAccessIter>::value_type>::is_iec559,
      void >::type
    float_sort(RandomAccessIter first, RandomAccessIter last)
    {
      size_t bin_sizes[1 << max_finishing_splits];
      std::vector<RandomAccessIter> bin_cache;
      float_sort_rec<RandomAccessIter, boost::int64_t, boost::uint64_t>
        (first, last, bin_cache, 0, bin_sizes);
    }

    template <class RandomAccessIter>
    inline typename boost::disable_if_c< (sizeof(boost::uint64_t) ==
      sizeof(typename std::iterator_traits<RandomAccessIter>::value_type)
      || sizeof(boost::uint32_t) ==
      sizeof(typename std::iterator_traits<RandomAccessIter>::value_type))
      && std::numeric_limits<typename
      std::iterator_traits<RandomAccessIter>::value_type>::is_iec559,
      void >::type
    float_sort(RandomAccessIter first, RandomAccessIter last)
    {
      BOOST_STATIC_WARNING(!(sizeof(boost::uint64_t) ==
      sizeof(typename std::iterator_traits<RandomAccessIter>::value_type)
      || sizeof(boost::uint32_t) ==
      sizeof(typename std::iterator_traits<RandomAccessIter>::value_type))
      || !std::numeric_limits<typename
      std::iterator_traits<RandomAccessIter>::value_type>::is_iec559);
      std::sort(first, last);
    }

    //These approaches require the user to do the typecast
    //with rshift but default comparision
    template <class RandomAccessIter, class Div_type, class Right_shift>
    inline typename boost::enable_if_c< sizeof(size_t) >= sizeof(Div_type),
      void >::type
    float_sort(RandomAccessIter first, RandomAccessIter last, Div_type,
               Right_shift rshift)
    {
      size_t bin_sizes[1 << max_finishing_splits];
      std::vector<RandomAccessIter> bin_cache;
      float_sort_rec<RandomAccessIter, Div_type, Right_shift, size_t>
        (first, last, bin_cache, 0, bin_sizes, rshift);
    }

    //maximum integer size with rshift but default comparision
    template <class RandomAccessIter, class Div_type, class Right_shift>
    inline typename boost::enable_if_c< sizeof(size_t) < sizeof(Div_type)
      && sizeof(boost::uintmax_t) >= sizeof(Div_type), void >::type
    float_sort(RandomAccessIter first, RandomAccessIter last, Div_type,
               Right_shift rshift)
    {
      size_t bin_sizes[1 << max_finishing_splits];
      std::vector<RandomAccessIter> bin_cache;
      float_sort_rec<RandomAccessIter, Div_type, Right_shift, boost::uintmax_t>
        (first, last, bin_cache, 0, bin_sizes, rshift);
    }

    //sizeof(Div_type) doesn't match, so use std::sort
    template <class RandomAccessIter, class Div_type, class Right_shift>
    inline typename boost::disable_if_c< sizeof(boost::uintmax_t) >=
      sizeof(Div_type), void >::type
    float_sort(RandomAccessIter first, RandomAccessIter last, Div_type,
               Right_shift rshift)
    {
      BOOST_STATIC_WARNING(sizeof(boost::uintmax_t) >= sizeof(Div_type));
      std::sort(first, last);
    }

    //specialized comparison
    template <class RandomAccessIter, class Div_type, class Right_shift,
              class Compare>
    inline typename boost::enable_if_c< sizeof(size_t) >= sizeof(Div_type),
      void >::type
    float_sort(RandomAccessIter first, RandomAccessIter last, Div_type,
               Right_shift rshift, Compare comp)
    {
      size_t bin_sizes[1 << max_finishing_splits];
      std::vector<RandomAccessIter> bin_cache;
      float_sort_rec<RandomAccessIter, Div_type, Right_shift, Compare,
        size_t>
        (first, last, bin_cache, 0, bin_sizes, rshift, comp);
    }

    //max-sized integer with specialized comparison
    template <class RandomAccessIter, class Div_type, class Right_shift,
              class Compare>
    inline typename boost::enable_if_c< sizeof(size_t) < sizeof(Div_type)
      && sizeof(boost::uintmax_t) >= sizeof(Div_type), void >::type
    float_sort(RandomAccessIter first, RandomAccessIter last, Div_type,
               Right_shift rshift, Compare comp)
    {
      size_t bin_sizes[1 << max_finishing_splits];
      std::vector<RandomAccessIter> bin_cache;
      float_sort_rec<RandomAccessIter, Div_type, Right_shift, Compare,
        boost::uintmax_t>
        (first, last, bin_cache, 0, bin_sizes, rshift, comp);
    }

    //sizeof(Div_type) doesn't match, so use std::sort
    template <class RandomAccessIter, class Div_type, class Right_shift,
              class Compare>
    inline typename boost::disable_if_c< sizeof(boost::uintmax_t) >=
      sizeof(Div_type), void >::type
    float_sort(RandomAccessIter first, RandomAccessIter last, Div_type,
               Right_shift rshift, Compare comp)
    {
      BOOST_STATIC_WARNING(sizeof(boost::uintmax_t) >= sizeof(Div_type));
      std::sort(first, last, comp);
    }
  }
}
}
}

#endif

redpajama_set_name: RedPajamaGithub


text:
FROM jetbrains/teamcity-agent:2017.1.4

RUN curl -L https://github.com/docker/compose/releases/download/1.16.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose \
    && chmod +x /usr/local/bin/docker-compose


text:
package org.apache.derby.iapi.types;

import org.apache.derby.iapi.error.StandardException;

/**
 * The VariableSizeDataValue interface corresponds to
 * Datatypes that have adjustable width.
 *
 * The following methods are defined herein:
 *		setWidth()
 *
 */
public interface VariableSizeDataValue
{

	public static int IGNORE_PRECISION = -1;

	/*
	 * Set the width and scale (if relevant).  Sort of a poor
	 * man's normalize.  Used when we need to normalize a datatype
	 * but we don't want to use a NormalizeResultSet (e.g.
	 * for an operator that can change the width/scale of a
	 * datatype, namely CastNode).
	 *
	 * @param desiredWidth width
	 * @param desiredScale scale, if relevant (ignored for strings)
	 * @param errorOnTrunc	throw an error on truncation of value
	 *
	 * @exception StandardException		Thrown on error
	 */
	public void setWidth(int desiredWidth,
									int desiredScale,
									boolean errorOnTrunc)
							throws StandardException;
}


text:
#pragma once
#include <aws/quicksight/QuickSight_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSVector.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/quicksight/model/AnalysisSummary.h>
#include <utility>

namespace Aws
{
template<typename RESULT_TYPE>
class AmazonWebServiceResult;

namespace Utils
{
namespace Json
{
  class JsonValue;
} // namespace Json
} // namespace Utils
namespace QuickSight
{
namespace Model
{
  class AWS_QUICKSIGHT_API SearchAnalysesResult
  {
  public:
    SearchAnalysesResult();
    SearchAnalysesResult(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result);
    SearchAnalysesResult& operator=(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result);

    /**
     *
Metadata describing the analyses that you searched for.

     */
    inline const Aws::Vector<AnalysisSummary>& GetAnalysisSummaryList() const{ return m_analysisSummaryList; }

    /**
     *
Metadata describing the analyses that you searched for.

     */
    inline void SetAnalysisSummaryList(const Aws::Vector<AnalysisSummary>& value) { m_analysisSummaryList = value; }

    /**
     *
Metadata describing the analyses that you searched for.

     */
    inline void SetAnalysisSummaryList(Aws::Vector<AnalysisSummary>&& value) { m_analysisSummaryList = std::move(value); }

    /**
     *
Metadata describing the analyses that you searched for.

     */
    inline SearchAnalysesResult& WithAnalysisSummaryList(const Aws::Vector<AnalysisSummary>& value) { SetAnalysisSummaryList(value); return *this;}

    /**
     *
Metadata describing the analyses that you searched for.

     */
    inline SearchAnalysesResult& WithAnalysisSummaryList(Aws::Vector<AnalysisSummary>&& value) { SetAnalysisSummaryList(std::move(value)); return *this;}

    /**
     *
Metadata describing the analyses that you searched for.

     */
    inline SearchAnalysesResult& AddAnalysisSummaryList(const AnalysisSummary& value) { m_analysisSummaryList.push_back(value); return *this; }

    /**
     *
Metadata describing the analyses that you searched for.

     */
    inline SearchAnalysesResult& AddAnalysisSummaryList(AnalysisSummary&& value) { m_analysisSummaryList.push_back(std::move(value)); return *this; }

    /**
     *
A pagination token that can be used in a subsequent request.

     */
    inline const Aws::String& GetNextToken() const{ return m_nextToken; }

    /**
     *
A pagination token that can be used in a subsequent request.

     */
    inline void SetNextToken(const Aws::String& value) { m_nextToken = value; }

    /**
     *
A pagination token that can be used in a subsequent request.

     */
    inline void SetNextToken(Aws::String&& value) { m_nextToken = std::move(value); }

    /**
     *
A pagination token that can be used in a subsequent request.

     */
    inline void SetNextToken(const char* value) { m_nextToken.assign(value); }

    /**
     *
A pagination token that can be used in a subsequent request.

     */
    inline SearchAnalysesResult& WithNextToken(const Aws::String& value) { SetNextToken(value); return *this;}

    /**
     *
A pagination token that can be used in a subsequent request.

     */
    inline SearchAnalysesResult& WithNextToken(Aws::String&& value) { SetNextToken(std::move(value)); return *this;}

    /**
     *
A pagination token that can be used in a subsequent request.

     */
    inline SearchAnalysesResult& WithNextToken(const char* value) { SetNextToken(value); return *this;}

    /**
     *
The HTTP status of the request.

     */
    inline int GetStatus() const{ return m_status; }

    /**
     *
The HTTP status of the request.

     */
    inline void SetStatus(int value) { m_status = value; }

    /**
     *
The HTTP status of the request.

     */
    inline SearchAnalysesResult& WithStatus(int value) { SetStatus(value); return *this;}

    /**
     *
The Amazon Web Services request ID for this operation.

     */
    inline const Aws::String& GetRequestId() const{ return m_requestId; }

    /**
     *
The Amazon Web Services request ID for this operation.

     */
    inline void SetRequestId(const Aws::String& value) { m_requestId = value; }

    /**
     *
The Amazon Web Services request ID for this operation.

     */
    inline void SetRequestId(Aws::String&& value) { m_requestId = std::move(value); }

    /**
     *
The Amazon Web Services request ID for this operation.

     */
    inline void SetRequestId(const char* value) { m_requestId.assign(value); }

    /**
     *
The Amazon Web Services request ID for this operation.

     */
    inline SearchAnalysesResult& WithRequestId(const Aws::String& value) { SetRequestId(value); return *this;}

    /**
     *
The Amazon Web Services request ID for this operation.

     */
    inline SearchAnalysesResult& WithRequestId(Aws::String&& value) { SetRequestId(std::move(value)); return *this;}

    /**
     *
The Amazon Web Services request ID for this operation.

     */
    inline SearchAnalysesResult& WithRequestId(const char* value) { SetRequestId(value); return *this;}

  private:

    Aws::Vector<AnalysisSummary> m_analysisSummaryList;

    Aws::String m_nextToken;

    int m_status;

    Aws::String m_requestId;
  };

} // namespace Model
} // namespace QuickSight
} // namespace Aws


text:
package com.navercorp.pinpoint.metric.common.model.validation;

import com.navercorp.pinpoint.metric.common.model.Metrics;
import com.navercorp.pinpoint.metric.common.model.SystemMetric;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import java.util.Collections;
import java.util.Set;

public class TelegrafMetricsValidatorTest {
    private final Logger logger = LogManager.getLogger(this.getClass());

    @Test
    public void testMetrics() {
        ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
        final Validator validator = validatorFactory.getValidator();

        SystemMetric systemMetric = new SystemMetric("", "fieldname", "hostName", Collections.emptyList(), System.currentTimeMillis());
        Metrics metrics = new Metrics("tenantId", "hostGroupName", "hostName", Collections.singletonList(systemMetric));

        Set<ConstraintViolation<Metrics>> result = validator.validate(metrics);

        Assertions.assertEquals(1, result.size());

        ConstraintViolationException invalid_metric = new ConstraintViolationException("invalid metric", result);
        logger.debug("{}", invalid_metric.toString());
    }
}


text:
<?php

namespace JMS\Serializer\Tests\Handler;

use Psr\Container\ContainerInterface;

class LazyHandlerRegistryWithPsr11ContainerTest extends LazyHandlerRegistryTest
{
    protected function createContainer()
    {
        return new Psr11Container();
    }

    protected function registerHandlerService($serviceId, $listener)
    {
        $this->container->set($serviceId, $listener);
    }
}

class Psr11Container implements ContainerInterface
{
    private $services;

    public function get($id)
    {
        return $this->services[$id];
    }

    public function has($id)
    {
        return isset($this->services[$id]);
    }

    public function set($id, $service)
    {
        $this->services[$id] = $service;
    }
}


text:
import React, { Component } from "react";
import axios from "axios";
import debounce from "lodash.debounce";
import {
  MuiThemeProvider,
  createMuiTheme,
  withStyles
} from "@material-ui/core/styles";

import {
  ApiClient,
  DatasetApi,
  FacetsApi,
  SearchApi
} from "data_explorer_service";
import colors from "libs/colors";
import DeHeader from "components/DeHeader";
import ExportUrlApi from "api/src/api/ExportUrlApi";
import FacetsGrid from "components/facets/FacetsGrid";
import { filterArrayToMap, filterMapToArray } from "libs/util";
import TerraHeader from "components/TerraHeader";
import Montserrat from "libs/fonts/Montserrat-Medium.woff2";

const styles = {
  disclaimer: {
    color: colors.dark(),
    fontSize: 14,
    padding: "15px 15px 5px 15px"
  },
  disclaimerLink: {
    color: "#295699",
    textDecoration: "none"
  },
  root: {
    backgroundColor: "#fafbfc",
    // 1) overflow-x=hidden is needed to disable horizontal scrollbar.
    // Horizontal scrollbar appears because each HistogramFacet has right
    // margin, including right-most HistogramFacets.
    // 2) With overflow-x=hidden, horizontal scrollbar disappears but with some
    // datasets (not 1000 Genomes) there are 2 vertical scrollbars.
    // overflow=hidden gets us down to one vertical scrollbar.
    overflow: "hidden"
  }
};

const theme = createMuiTheme({
  typography: {
    fontFamily: ["Montserrat", "sans-serif"].join(","),
    useNextVariants: true
  }
});

const ThousandGenomesDisclaimer = function(classes) {
  return (

      This dataset is publicly available for anyone to use under the terms
      provided by the dataset source (

        http://www.internationalgenome.org/data

      ) and are provided "AS IS" without any warranty, express or implied, from
      Verily Life Sciences, LLC. Verily Life Sciences, LLC disclaims all
      liability for any damages, direct or indirect, resulting from the use of
      the dataset.

  );
};

const FraminghamDisclaimer = function(classes) {
  return (

      This dataset is publicly available for anyone to use under the terms
      provided by the dataset source (

        https://biolincc.nhlbi.nih.gov/teaching

      ) and are provided "AS IS" without any warranty, express or implied, from
      Verily Life Sciences, LLC. Verily Life Sciences, LLC disclaims all
      liability for any damages, direct or indirect, resulting from the use of
      the dataset. This is a teaching dataset and may not be used for
      publication.

  );
};

class App extends Component {
  constructor(props) {
    super(props);

    this.state = {
      // If embed is true: DE is embedded in an iframe in Terra. Top-level URL
      // looks like https://app.terra.bio/#library/datasets/1000%20Genomes/data-explorer
      // If embed is false: DE is stand-alone. Top-level URL looks like
      // https://test-data-explorer.appspot.com
      embed: new URLSearchParams(window.location.search).has("embed"),
      datasetName: "",
      // What to show in search box by default. If this is the empty string, the
      // react-select default of "Select..." is shown.
      searchPlaceholderText: "",
      // Map from es_field_name to facet data returned from API server /facets call.
      facets: new Map(),
      totalCount: null,
      // Map from es_field_name to a list of selected facet values.
      selectedFacetValues: new Map(),
      // These represent extra facets added via the search box.
      // This is an array of Elasticsearch field names
      extraFacetEsFieldNames: [],
      // Search results shown in the search drop-down.
      // This is an array of dicts, where each dict has
      // facetName - The name of the facet.
      // facetDescription - The description of the facet.
      // esFieldName - The elasticsearch field name of the facet.
      // facetValue
      searchResults: [],
      facetsApiDone: false,
      fontLoaded: false,
      sqlQuery: ""
      // SQL query that can be used in BigQuery to get the cohort
      // (list of participants) of the current filter.
    };

    this.apiClient = new ApiClient();
    this.apiClient.basePath = "/api";
    this.facetsApi = new FacetsApi(this.apiClient);
    this.facetsCallback = function(error, data) {
      if (error) {
        this.setState({ facetsApiDone: true });
        console.error(error);
      } else {
        this.setState({
          facetsApiDone: true,
          facets: this.getFacetMap(data.facets),
          invalidFilterFacets: data.invalid_filter_facets,
          invalidExtraFacets: data.invalid_extra_facets,
          totalCount: data.count,
          sqlQuery: data.sql_query
        });

        const pipe = encodeURIComponent("|");
        if (data.invalid_filter_facets && data.invalid_filter_facets.length) {
          // Delete invalid filter params so if user tries to save a cohort,
          // cohort won't have invalid param.
          // Also, there is no chip for invalid filter. So delete invalid parts
          // of filter param so filter param matches chips.
          const params = new URLSearchParams(window.location.search);
          const filterParam = params
            .get("filter")
            .split(pipe)
            .filter(
              filter =>
                !data.invalid_filter_facets.some(invalidFacet =>
                  filter.includes(invalidFacet)
                )
            )
            .join(encodeURIComponent("|"));
          this.updateQueryString(filterParam, params.get("extraFacets"));
        }
        if (data.invalid_extra_facets && data.invalid_extra_facets.length) {
          // Delete invalid extraFacets params so if user tries to save a cohort,
          // cohort won't have invalid param.
          const params = new URLSearchParams(window.location.search);
          const extraFacetsParam = params
            .get("extraFacets")
            .split(pipe)
            .filter(
              extraFacet => !data.invalid_extra_facets.includes(extraFacet)
            )
            .join(encodeURIComponent("|"));
          this.updateQueryString(params.get("filter"), extraFacetsParam);
        }
      }
    }.bind(this);

    this.searchApi = new SearchApi(this.apiClient);

    this.searchCallback = function(error, data) {
      if (error) {
        console.error(error);
      } else {
        let search_results = data.search_results.map(result => {
          return {
            facetName: result.facet_name,
            facetDescription: result.facet_description,
            esFieldName: result.elasticsearch_field_name,
            facetValue: result.facet_value,
            isTimeSeries: result.is_time_series
          };
        });
        this.setState({
          searchResults: search_results
        });
      }
    }.bind(this);

    // debounce so we don't call API server query after every letter; only after a pause in typing
    this.handleSearchBoxTyping = debounce((inputValue, callback) => {
      // axios is needed to avoid setTimeout from react-select examples at https://react-select.com/async.
      let apiUrl = this.apiClient.buildUrl("search?query=" + inputValue);
      axios
        .get(`${apiUrl}`)
        .then(({ data }) => {
          var result = data.search_results.map(searchResult => {
            return {
              facetName: searchResult.facet_name,
              facetDescription: searchResult.facet_description,
              esFieldName: searchResult.elasticsearch_field_name,
              facetValue: searchResult.facet_value,
              isTimeSeries: searchResult.is_time_series
            };
          });
          callback(result);
        })
        .catch(error => callback(error, null));
    }, 500).bind(this);

    this.loadFont();

    this.updateFacets = this.updateFacets.bind(this);
    this.handleSearchBoxChange = this.handleSearchBoxChange.bind(this);
    this.handleSearchBoxTyping = this.handleSearchBoxTyping.bind(this);
    this.handleRemoveFacet = this.handleRemoveFacet.bind(this);
  }

  shouldComponentUpdate(nextProps, nextState) {
    return nextState.facetsApiDone && nextState.fontLoaded;
  }

  render() {
    const { classes } = this.props;

    if (this.state.facets.size === 0 || this.state.datasetName === "") {
      // Server has not yet responded or returned an error
      return
;
    } else {
      return (
        <MuiThemeProvider theme={theme}>

            {!this.state.embed && (
              <TerraHeader datasetName={this.state.datasetName} />
            )}
            <DeHeader
              datasetName={this.state.datasetName}
              embed={this.state.embed}
              exportUrlApi={new ExportUrlApi(this.apiClient)}
              facets={this.state.facets}
              handleSearchBoxChange={this.handleSearchBoxChange}
              handleSearchBoxTyping={this.handleSearchBoxTyping}
              invalidFilterFacets={this.state.invalidFilterFacets}
              invalidExtraFacets={this.state.invalidExtraFacets}
              searchPlaceholderText={this.state.searchPlaceholderText}
              searchResults={this.state.searchResults}
              selectedFacetValues={this.state.selectedFacetValues}
              totalCount={this.state.totalCount}
              timeSeriesUnit={this.state.timeSeriesUnit}
              sqlQuery={this.state.sqlQuery}
            />
            <FacetsGrid
              updateFacets={this.updateFacets}
              selectedFacetValues={this.state.selectedFacetValues}
              facets={Array.from(this.state.facets.values())}
              handleRemoveFacet={this.handleRemoveFacet}
              extraFacetEsFieldNames={this.state.extraFacetEsFieldNames}
              timeSeriesUnit={this.state.timeSeriesUnit}
            />
            {this.state.datasetName === "1000 Genomes"
              ? ThousandGenomesDisclaimer(classes)
              : this.state.datasetName ===
                "Framingham Heart Study Teaching Dataset"
              ? FraminghamDisclaimer(classes)
              : null}

        </MuiThemeProvider>
      );
    }
  }

  componentDidMount() {
    this.searchApi.searchGet({}, this.searchCallback);

    if (window.location.search) {
      this.handleQueryString();
    } else {
      this.callFacetsApiGet({}, this.facetsCallback);
    }

    // Call /api/dataset
    let datasetApi = new DatasetApi(this.apiClient);
    let datasetCallback = function(error, data) {
      if (error) {
        // TODO: Show error in snackbar.
        console.error(error);
      } else {
        this.setState({
          datasetName: data.name,
          searchPlaceholderText: data.search_placeholder_text,
          timeSeriesUnit: data.time_series_unit
        });
      }
    }.bind(this);
    datasetApi.datasetGet(datasetCallback);
  }

  loadFont() {
    // Force load font before vega rendering to prevent truncation bug. See
    // https://github.com/vega/vega/issues/1671
    // If we preloaded the font in HistogramFacet.js, then the page would render
    // in two stages: 1) header and search box, 2) facets. Preload here so the
    // entire page renders at once.
    var font = new FontFace("Montserrat", "url(" + Montserrat + ")");
    font.load().then(loadedFace => {
      document.fonts.add(loadedFace);
      this.setState({ fontLoaded: true });
    });
  }

  getFacetMap(facets) {
    var facetMap = new Map();
    facets.forEach(function(facet) {
      facetMap.set(facet.es_field_name, facet);
    });
    return facetMap;
  }

  handleSearchBoxChange(selectedOptions, action) {
    if (action.action === "clear") {
      // x on right of search box was clicked.
      this.setState({ selectedFacetValues: new Map() });
      this.callFacetsApiGet(
        {
          filter: filterMapToArray(new Map()),
          extraFacets: this.state.extraFacetEsFieldNames
        },
        this.facetsCallback
      );
    } else if (action.action === "remove-value") {
      // chip x was clicked.
      let parts = action.removedValue.value.split("=");
      this.updateFacets(parts[0], parts[1], false);
    } else if (action.action === "select-option") {
      let option = action.option;
      // Drop-down row was clicked.
      let newExtraFacetEsFieldNames = this.state.extraFacetEsFieldNames;
      let facetEsFieldName =
        option.isTimeSeries && option.facetValue
          ? option.esFieldName
              .split(".")
              .slice(0, -1)
              .join(".")
          : option.esFieldName;
      newExtraFacetEsFieldNames.push(facetEsFieldName);

      let selectedFacetValues = this.state.selectedFacetValues;
      if (option.facetValue !== "") {
        selectedFacetValues = this.updateSelectedFacetValues(
          option.esFieldName,
          option.facetValue,
          true
        );
      }

      this.callFacetsApiGet(
        {
          filter: filterMapToArray(selectedFacetValues),
          extraFacets: newExtraFacetEsFieldNames
        },
        function(error, data) {
          this.facetsCallback(error, data);
          this.setState({
            // Set selectedFacetValues state after facetsCallback.
            // If it were set before, the relevant facet might not yet be in extraFacetEsFieldsNames.
            selectedFacetValues: selectedFacetValues,
            extraFacetEsFieldNames: newExtraFacetEsFieldNames
          });
        }.bind(this)
      );
    }
  }

  // Return new selectedFacetValues representing current state and the facet value that was just de/selected
  updateSelectedFacetValues(esFieldName, facetValue, isSelected) {
    let allFacetValues = this.state.selectedFacetValues;
    let facetValuesForField = allFacetValues.get(esFieldName);
    if (isSelected) {
      // Add facetValue to the list of filters for facetName
      if (facetValuesForField === undefined) {
        allFacetValues.set(esFieldName, [facetValue]);
      } else if (!facetValuesForField.includes(facetValue)) {
        facetValuesForField.push(facetValue);
      }
    } else if (allFacetValues.get(esFieldName) !== undefined) {
      // Remove facetValue from the list of filters for facetName
      allFacetValues.set(
        esFieldName,
        facetValuesForField.filter(n => n !== facetValue)
      );
    }
    return allFacetValues;
  }

  /**
   * Updates the selection for a single facet value and refreshes the facets data from the server.
   * */
  updateFacets(esFieldName, facetValue, isSelected) {
    let selectedFacetValues = this.updateSelectedFacetValues(
      esFieldName,
      facetValue,
      isSelected
    );
    this.setState({
      facetsApiDone: false,
      selectedFacetValues: selectedFacetValues
    });
    this.callFacetsApiGet(
      {
        filter: filterMapToArray(this.state.selectedFacetValues),
        extraFacets: this.state.extraFacetEsFieldNames
      },
      this.facetsCallback
    );
  }

  handleRemoveFacet(facetValue) {
    let facetsCopy = new Map(this.state.facets);
    facetsCopy.delete(facetValue);
    let selectedFacetValues = new Map(this.state.selectedFacetValues);
    for (const facetValueKey of selectedFacetValues.keys()) {
      if (
        facetValueKey === facetValue ||
        facetValueKey
          .split(".")
          .slice(0, -1)
          .join(".") === facetValue
      ) {
        selectedFacetValues.delete(facetValueKey);
      }
    }
    let extraFacetEsFieldNames = this.state.extraFacetEsFieldNames.filter(
      n => n !== facetValue
    );
    this.setState({
      facetsApiDone: false,
      facets: facetsCopy,
      extraFacetEsFieldNames: extraFacetEsFieldNames,
      selectedFacetValues: selectedFacetValues
    });
    this.callFacetsApiGet(
      {
        filter: filterMapToArray(selectedFacetValues),
        extraFacets: extraFacetEsFieldNames
      },
      this.facetsCallback
    );
  }

  handleQueryString() {
    var params = new URLSearchParams(window.location.search);
    var pipe = encodeURIComponent("|");
    var filter = params.get("filter") ? params.get("filter").split(pipe) : [];
    // filter looks like ["Gender%3Dfemale", "Gender%3Dmale", "Population%3DAmerican"]
    var extraFacets = params.get("extraFacets")
      ? params.get("extraFacets").split(pipe)
      : [];
    this.callFacetsApiGet(
      {
        filter: filter,
        extraFacets: extraFacets
      },
      function(error, data) {
        this.facetsCallback(error, data);
        this.setState({
          // Set selectedFacetValues state after facetsCallback.
          // If it were set before, the relevant facet might not yet be in extraFacetEsFieldsNames.
          selectedFacetValues: filterArrayToMap(
            filter,
            data.invalid_filter_facets
          ),
          extraFacetEsFieldNames: extraFacets
        });
      }.bind(this)
    );
  }

  updateQueryString(filterParam, extraFacetsParam) {
    // If there are any params other than filter/extraFacets, leave as-is.
    var params = new URLSearchParams(window.location.search);
    params.set("filter", filterParam);
    params.set("extraFacets", extraFacetsParam);
    window.history.replaceState(null, "", "?" + params.toString());

    // Tell Terra about new params so top-level Terra url can be updated
    if (this.state.embed && "parentIFrame" in window) {
      params.delete("embed");
      // Don't set targetOrigin because it's unknown. It could be app.terra.bio,
      // bvdp-saturn-dev.appspot.com, etc.
      window.parentIFrame.sendMessage({ deQueryStr: params.toString() });
    }
  }

  // Wrap the call to facetsGet together with updating the query params
  callFacetsApiGet(data, facetsCallback) {
    this.facetsApi.facetsGet(data, facetsCallback);
    let extraFacetsParam = (data.extraFacets || []).join(
      encodeURIComponent("|")
    );
    let filterParam = (data.filter || [])
      .map(f => f.replace("=", encodeURIComponent("=")))
      .join(encodeURIComponent("|"));
    this.updateQueryString(filterParam, extraFacetsParam);
  }
}

export default withStyles(styles)(App);


text:
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class NumberInserter
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.btnClose = New System.Windows.Forms.Button()
        Me.txtInsertFrom = New System.Windows.Forms.TextBox()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.txtInsertTo = New System.Windows.Forms.TextBox()
        Me.Label3 = New System.Windows.Forms.Label()
        Me.txtInsertSeperator = New System.Windows.Forms.TextBox()
        Me.btnInsertGo = New System.Windows.Forms.Button()
        Me.Label4 = New System.Windows.Forms.Label()
        Me.txtInsertStep = New System.Windows.Forms.TextBox()
        Me.SuspendLayout
        '
        'Label1
        '
        Me.Label1.AutoSize = true
        Me.Label1.Location = New System.Drawing.Point(12, 9)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(102, 13)
        Me.Label1.TabIndex = 19
        Me.Label1.Text = "Insert numbers from:"
        '
        'btnClose
        '
        Me.btnClose.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.btnClose.AutoSize = true
        Me.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.btnClose.Location = New System.Drawing.Point(199, 62)
        Me.btnClose.Name = "btnClose"
        Me.btnClose.Size = New System.Drawing.Size(75, 23)
        Me.btnClose.TabIndex = 10
        Me.btnClose.Text = "Close"
        Me.btnClose.UseVisualStyleBackColor = true
        '
        'txtInsertFrom
        '
        Me.txtInsertFrom.Location = New System.Drawing.Point(12, 25)
        Me.txtInsertFrom.Name = "txtInsertFrom"
        Me.txtInsertFrom.Size = New System.Drawing.Size(60, 20)
        Me.txtInsertFrom.TabIndex = 20
        Me.txtInsertFrom.Text = "1"
        '
        'Label2
        '
        Me.Label2.AutoSize = true
        Me.Label2.Location = New System.Drawing.Point(78, 28)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(16, 13)
        Me.Label2.TabIndex = 21
        Me.Label2.Text = "to"
        '
        'txtInsertTo
        '
        Me.txtInsertTo.Location = New System.Drawing.Point(100, 25)
        Me.txtInsertTo.Name = "txtInsertTo"
        Me.txtInsertTo.Size = New System.Drawing.Size(73, 20)
        Me.txtInsertTo.TabIndex = 22
        Me.txtInsertTo.Text = "200"
        '
        'Label3
        '
        Me.Label3.AutoSize = true
        Me.Label3.Location = New System.Drawing.Point(12, 48)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(81, 13)
        Me.Label3.TabIndex = 23
        Me.Label3.Text = "With Seperator:"
        '
        'txtInsertSeperator
        '
        Me.txtInsertSeperator.Location = New System.Drawing.Point(12, 64)
        Me.txtInsertSeperator.Name = "txtInsertSeperator"
        Me.txtInsertSeperator.Size = New System.Drawing.Size(100, 20)
        Me.txtInsertSeperator.TabIndex = 24
        Me.txtInsertSeperator.Text = "{ENTER}"
        '
        'btnInsertGo
        '
        Me.btnInsertGo.Location = New System.Drawing.Point(118, 62)
        Me.btnInsertGo.Name = "btnInsertGo"
        Me.btnInsertGo.Size = New System.Drawing.Size(75, 23)
        Me.btnInsertGo.TabIndex = 25
        Me.btnInsertGo.Text = "Go"
        Me.btnInsertGo.UseVisualStyleBackColor = true
        '
        'Label4
        '
        Me.Label4.AutoSize = true
        Me.Label4.Location = New System.Drawing.Point(179, 28)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(29, 13)
        Me.Label4.TabIndex = 26
        Me.Label4.Text = "Step"
        '
        'txtInsertStep
        '
        Me.txtInsertStep.Location = New System.Drawing.Point(214, 25)
        Me.txtInsertStep.Name = "txtInsertStep"
        Me.txtInsertStep.Size = New System.Drawing.Size(60, 20)
        Me.txtInsertStep.TabIndex = 27
        Me.txtInsertStep.Text = "1"
        '
        'NumberInserter
        '
        Me.AcceptButton = Me.btnInsertGo
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6!, 13!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.CancelButton = Me.btnClose
        Me.ClientSize = New System.Drawing.Size(286, 97)
        Me.Controls.Add(Me.txtInsertStep)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.btnClose)
        Me.Controls.Add(Me.btnInsertGo)
        Me.Controls.Add(Me.txtInsertFrom)
        Me.Controls.Add(Me.txtInsertSeperator)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.txtInsertTo)
        Me.Name = "NumberInserter"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "NumberInserter"
        Me.ResumeLayout(false)
        Me.PerformLayout
    End Sub
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents btnClose As System.Windows.Forms.Button
    Friend WithEvents txtInsertFrom As System.Windows.Forms.TextBox
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents txtInsertTo As System.Windows.Forms.TextBox
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents txtInsertSeperator As System.Windows.Forms.TextBox
    Friend WithEvents btnInsertGo As System.Windows.Forms.Button
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents txtInsertStep As System.Windows.Forms.TextBox
End Class


text:
<?php

require_once realpath(dirname(__FILE__) . '/bootstrap.php');

$container = Zend_Registry::get('doctrine');

// Console
$cli = new \Symfony\Component\Console\Application(
    'Doctrine Command Line Interface',
    \Doctrine\Common\Version::VERSION
);

try {
    // Bootstrapping Console HelperSet
    $helperSet = array();

    if (($dbal = $container->getConnection(getenv('CONN') ?: $container->defaultConnection)) !== null) {
        $helperSet['db'] = new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($dbal);
    }

    if (($em = $container->getEntityManager(getenv('EM') ?: $container->defaultEntityManager)) !== null) {
        $helperSet['em'] = new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em);
    }
} catch (\Exception $e) {
    $cli->renderException($e, new \Symfony\Component\Console\Output\ConsoleOutput());
}

$cli->setCatchExceptions(true);
$cli->setHelperSet(new \Symfony\Component\Console\Helper\HelperSet($helperSet));

$cli->addCommands(array(
    // DBAL Commands
    new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(),
    new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(),

    // ORM Commands
    new \Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(),
    new \Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(),
    new \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand(),
    new \Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand(),
    new \Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand(),
    new \Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand(),
    new \Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand(),
    new \Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand(),
    new \Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand(),
    new \Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand(),
    new \Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(),
    new \Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand(),
    new \Doctrine\ORM\Tools\Console\Command\RunDqlCommand(),
    new \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand(),

));

$cli->run();


text:
echo Preparing to up admin and nodes
#
# Generating ssh keys to allow access to minions from master node
#
rm -f ./common/id_*
ssh-keygen -f ./common/id_rsa -P ""
chmod +x common/*.sh


text:
> A grunt command to run 1 off tasks with sails

## Getting Started
This plugin requires Grunt `~0.4.5`

If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

```shell
npm install grunt-sails-tasks --save-dev
```

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

```js
grunt.loadNpmTasks('grunt-sails-tasks');
```

## The "sails_tasks" task

### Overview
In your project's Gruntfile, add a section named `sails_tasks` to the data object passed into `grunt.initConfig()`.

```js
grunt.initConfig({
  sails_tasks: {
    your_target: {
      functions: [ functionOne, functionTwo ]
    },
  },
});
```

### Data

#### data.functions
Type: `Array of functions`
Required

An array of functions to execute. The functions are executed using the (async)[https://github.com/caolan/async] framework, so each function should take one parameter that is a callback function.

```js
functions: [
  function (callback) {
    // do something
    callback();
  },
  function (callback) {
    // do something else
    callback();
  }
]

```

#### data.series
Type: `Boolean`
Default value: `false`

If `true`, `async.series` will be used to execute the functions. The default is `false`, in which case `async.parallel` will be used.

### Usage Examples

#### Default Options
We use this grunt task to do a number of things on each deployment. One of the things we do is seed data into the database. There are a number of repos out there that deal with seeding data for sails, but we needed slightly more flexibility, and opted to write our own code to seed the data.

```js
grunt.initConfig({
  sails_tasks: {
    seed: {
      functions: [
        function (callback) {
          // Seed some config data
          callback();
        },
        function (callback) {
          // Seed some example data
          callback();
        }
      ]
    }
  }
});
```

This task will run this code like below, after lifting sails.

```js
async.parallel([
  function (callback) {
    // Seed some config data
    callback();
  },
  function (callback) {
    // Seed some example data
    callback();
  }
], cb);
```

#### Series
In some cases, you may want to run your functions in series, rather than in parallel. Note that it's nearly as easy to just create one function for the `sails_tasks` functions array that then calls the functions in series. This just removes the need to nest that one extra level.

```js
grunt.initConfig({
  sails_tasks: {
    options: {
      series: true
    },
    seed: {
      functions: [
        function (callback) {
          // Seed some config data
          callback();
        },
        function (callback) {
          // Seed some example data
          callback();
        }
      ]
    }
  }
});
```

This task will run this code like below, after lifting sails.

```js
async.series([
  function (callback) {
    // Seed some config data
    callback();
  },
  function (callback) {
    // Seed some example data
    callback();
  }
], cb);
```

## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).

## Release History
_(Nothing yet)_


text:
package main

import (
	"bytes"
	"github.com/scalingdata/goavro"
	"log"
)

func main() {
	recordSchemaJSON := `
{
  "type": "record",
  "name": "comments",
  "doc:": "A basic schema for storing blog comments",
  "namespace": "com.example",
  "fields": [
    {
      "doc": "Name of user",
      "type": "string",
      "name": "username"
    },
    {
      "doc": "The content of the user's message",
      "type": "string",
      "name": "comment"
    },
    {
      "doc": "Unix epoch time in milliseconds",
      "type": "long",
      "name": "timestamp"
    }
  ]
}
`
	someRecord, err := goavro.NewRecord(goavro.RecordSchema(recordSchemaJSON))
	if err != nil {
		log.Fatal(err)
	}
	// identify field name to set datum for
	someRecord.Set("username", "Aquaman")
	someRecord.Set("comment", "The Atlantic is oddly cold this morning!")
	// you can fully qualify the field name
	someRecord.Set("com.example.timestamp", int64(1082196484))

	codec, err := goavro.NewCodec(recordSchemaJSON)
	if err != nil {
		log.Fatal(err)
	}

	bb := new(bytes.Buffer)
	if err = codec.Encode(bb, someRecord); err != nil {
		log.Fatal(err)
	}

	actual := bb.Bytes()
	expected := []byte("\x0eAquamanPThe Atlantic is oddly cold this morning!\x88\x88\x88\x88\x08")
	if bytes.Compare(actual, expected) != 0 {
		log.Printf("Actual: %#v; Expected: %#v", actual, expected)
	}
}