text:
// Copyright (C) 2007  Davis E. King (davis@dlib.net)
// License: Boost Software License   See LICENSE.txt for the full license.
#ifndef DLIB_BAYES_UTILs_
#define DLIB_BAYES_UTILs_

#include "bayes_utils_abstract.h"

#include "../string.h"
#include "../map.h"
#include "../matrix.h"
#include "../rand.h"
#include "../array.h"
#include "../set.h"
#include "../algs.h"
#include "../noncopyable.h"
#include "../smart_pointers.h"
#include "../graph.h"
#include <vector>
#include <algorithm>
#include <ctime>

namespace dlib
{

// ----------------------------------------------------------------------------------------

    class assignment
    {
    public:

        assignment()
        {
        }

        assignment(
            const assignment& a
        )
        {
            a.reset();
            while (a.move_next())
            {
                unsigned long idx = a.element().key();
                unsigned long value = a.element().value();
                vals.add(idx,value);
            }
        }

        assignment& operator = (
            const assignment& rhs
        )
        {
            if (this == &rhs)
                return *this;

            assignment(rhs).swap(*this);
            return *this;
        }

        void clear()
        {
            vals.clear();
        }

        bool operator < (
            const assignment& item
        ) const
        {
            if (size() < item.size())
                return true;
            else if (size() > item.size())
                return false;

            reset();
            item.reset();
            while (move_next())
            {
                item.move_next();
                if (element().key() < item.element().key())
                    return true;
                else if (element().key() > item.element().key())
                    return false;
                else if (element().value() < item.element().value())
                    return true;
                else if (element().value() > item.element().value())
                    return false;
            }

            return false;
        }

        bool has_index (
            unsigned long idx
        ) const
        {
            return vals.is_in_domain(idx);
        }

        void add (
            unsigned long idx,
            unsigned long value = 0
        )
        {
            // make sure requires clause is not broken
            DLIB_ASSERT( has_index(idx) == false ,
                         "\tvoid assignment::add(idx)"
                         << "\n\tYou can't add the same index to an assignment object more than once"
                         << "\n\tidx:  " << idx
                         << "\n\tthis: " << this
            );

            vals.add(idx, value);
        }

        unsigned long& operator[] (
            const long idx
        )
        {
            // make sure requires clause is not broken
            DLIB_ASSERT( has_index(idx) == true ,
                         "\tunsigned long assignment::operator[](idx)"
                         << "\n\tYou can't access an index value if it isn't already in the object"
                         << "\n\tidx:  " << idx
                         << "\n\tthis: " << this
            );

            return vals[idx];
        }

        const unsigned long& operator[] (
            const long idx
        ) const
        {
            // make sure requires clause is not broken
            DLIB_ASSERT( has_index(idx) == true ,
                         "\tunsigned long assignment::operator[](idx)"
                         << "\n\tYou can't access an index value if it isn't already in the object"
                         << "\n\tidx:  " << idx
                         << "\n\tthis: " << this
            );

            return vals[idx];
        }

        void swap (
            assignment& item
        )
        {
            vals.swap(item.vals);
        }

        void remove (
            unsigned long idx
        )
        {
            // make sure requires clause is not broken
            DLIB_ASSERT( has_index(idx) == true ,
                         "\tunsigned long assignment::remove(idx)"
                         << "\n\tYou can't remove an index value if it isn't already in the object"
                         << "\n\tidx:  " << idx
                         << "\n\tthis: " << this
            );

            vals.destroy(idx);
        }

        unsigned long size() const { return vals.size(); }

        void reset() const { vals.reset(); }

        bool move_next() const { return vals.move_next(); }

        map_pair<unsigned long, unsigned long>& element()
        {
            // make sure requires clause is not broken
            DLIB_ASSERT(current_element_valid() == true,
                        "\tmap_pair<unsigned long,unsigned long>& assignment::element()"
                        << "\n\tyou can't access the current element if it doesn't exist"
                        << "\n\tthis: " << this
            );
            return vals.element();
        }

        const map_pair<unsigned long, unsigned long>& element() const
        {
            // make sure requires clause is not broken
            DLIB_ASSERT(current_element_valid() == true,
                        "\tconst map_pair<unsigned long,unsigned long>& assignment::element() const"
                        << "\n\tyou can't access the current element if it doesn't exist"
                        << "\n\tthis: " << this
            );

            return vals.element();
        }

        bool at_start() const { return vals.at_start(); }

        bool current_element_valid() const { return vals.current_element_valid(); }

        friend inline void serialize (
            const assignment& item,
            std::ostream& out
        )
        {
            serialize(item.vals, out);
        }

        friend inline void deserialize (
            assignment& item,
            std::istream& in
        )
        {
            deserialize(item.vals, in);
        }

    private:
        mutable dlib::map<unsigned long, unsigned long>::kernel_1b_c vals;
    };

    inline std::ostream& operator << (
        std::ostream& out,
        const assignment& a
    )
    {
        a.reset();
        out << "(";
        if (a.move_next())
            out << a.element().key() << ":" << a.element().value();

        while (a.move_next())
        {
            out << ", " << a.element().key() << ":" << a.element().value();
        }

        out << ")";
        return out;
    }

    inline void swap (
        assignment& a,
        assignment& b
    )
    {
        a.swap(b);
    }

// ------------------------------------------------------------------------

    class joint_probability_table
    {
        /*!
            INITIAL VALUE
                - table.size() == 0

            CONVENTION
                - size() == table.size()
                - probability(a) == table[a]
        !*/
    public:

        joint_probability_table (
            const joint_probability_table& t
        )
        {
            t.reset();
            while (t.move_next())
            {
                assignment a = t.element().key();
                double p = t.element().value();
                set_probability(a,p);
            }
        }

        joint_probability_table() {}

        joint_probability_table& operator= (
            const joint_probability_table& rhs
        )
        {
            if (this == &rhs)
                return *this;
            joint_probability_table(rhs).swap(*this);
            return *this;
        }

        void set_probability (
            const assignment& a,
            double p
        )
        {
            // make sure requires clause is not broken
            DLIB_ASSERT(0.0 <= p && p <= 1.0,
                        "\tvoid& joint_probability_table::set_probability(a,p)"
                        << "\n\tyou have given an invalid probability value"
                        << "\n\tp:    " << p
                        << "\n\ta:    " << a
                        << "\n\tthis: " << this
            );

            if (table.is_in_domain(a))
            {
                table[a] = p;
            }
            else
            {
                assignment temp(a);
                table.add(temp,p);
            }
        }

        bool has_entry_for (
            const assignment& a
        ) const
        {
            return table.is_in_domain(a);
        }

        void add_probability (
            const assignment& a,
            double p
        )
        {
            // make sure requires clause is not broken
            DLIB_ASSERT(0.0 <= p && p <= 1.0,
                        "\tvoid& joint_probability_table::add_probability(a,p)"
                        << "\n\tyou have given an invalid probability value"
                        << "\n\tp:    " << p
                        << "\n\ta:    " << a
                        << "\n\tthis: " << this
            );

            if (table.is_in_domain(a))
            {
                table[a] += p;
                if (table[a] > 1.0)
                    table[a] = 1.0;
            }
            else
            {
                assignment temp(a);
                table.add(temp,p);
            }
        }

        double probability (
            const assignment& a
        ) const
        {
            return table[a];
        }

        void clear()
        {
            table.clear();
        }

        unsigned long size () const { return table.size(); }
        bool move_next() const { return table.move_next(); }
        void reset() const { table.reset(); }
        map_pair<assignment,double>& element()
        {
            // make sure requires clause is not broken
            DLIB_ASSERT(current_element_valid() == true,
                        "\tmap_pair<assignment,double>& joint_probability_table::element()"
                        << "\n\tyou can't access the current element if it doesn't exist"
                        << "\n\tthis: " << this
            );

            return table.element();
        }

        const map_pair<assignment,double>& element() const
        {
            // make sure requires clause is not broken
            DLIB_ASSERT(current_element_valid() == true,
                        "\tconst map_pair<assignment,double>& joint_probability_table::element() const"
                        << "\n\tyou can't access the current element if it doesn't exist"
                        << "\n\tthis: " << this
            );

            return table.element();
        }

        bool at_start() const { return table.at_start(); }

        bool current_element_valid() const { return table.current_element_valid(); }

        template <typename T>
        void marginalize (
            const T& vars,
            joint_probability_table& out
        ) const
        {
            out.clear();
            double p;
            reset();
            while (move_next())
            {
                assignment a;
                const assignment& asrc = element().key();
                p = element().value();

                asrc.reset();
                while (asrc.move_next())
                {
                    if (vars.is_member(asrc.element().key()))
                        a.add(asrc.element().key(), asrc.element().value());
                }

                out.add_probability(a,p);
            }
        }

        void marginalize (
            const unsigned long var,
            joint_probability_table& out
        ) const
        {
            out.clear();
            double p;
            reset();
            while (move_next())
            {
                assignment a;
                const assignment& asrc = element().key();
                p = element().value();

                asrc.reset();
                while (asrc.move_next())
                {
                    if (var == asrc.element().key())
                        a.add(asrc.element().key(), asrc.element().value());
                }

                out.add_probability(a,p);
            }
        }

        void normalize (
        )
        {
            double sum = 0;

            reset();
            while (move_next())
                sum += element().value();

            reset();
            while (move_next())
                element().value() /= sum;
        }

        void swap (
            joint_probability_table& item
        )
        {
            table.swap(item.table);
        }

        friend inline void serialize (
            const joint_probability_table& item,
            std::ostream& out
        )
        {
            serialize(item.table, out);
        }

        friend inline void deserialize (
            joint_probability_table& item,
            std::istream& in
        )
        {
            deserialize(item.table, in);
        }

    private:

        dlib::map<assignment, double >::kernel_1b_c table;
    };

    inline void swap (
        joint_probability_table& a,
        joint_probability_table& b
    ) { a.swap(b); }

// ----------------------------------------------------------------------------------------

    class conditional_probability_table : noncopyable
    {
        /*!
            INITIAL VALUE
                - table.size() == 0

            CONVENTION
                - if (table.is_in_domain(ps) && value < num_vals && table[ps](value) >= 0) then
                    - has_entry_for(value,ps) == true
                    - probability(value,ps) == table[ps](value)
                - else
                    - has_entry_for(value,ps) == false

                - num_values() == num_vals
        !*/
    public:

        conditional_probability_table()
        {
            clear();
        }

        void set_num_values (
            unsigned long num
        )
        {
            num_vals = num;
            table.clear();
        }

        bool has_entry_for (
            unsigned long value,
            const assignment& ps
        ) const
        {
            if (table.is_in_domain(ps) && value < num_vals && table[ps](value) >= 0)
                return true;
            else
                return false;
        }

        unsigned long num_values (
        ) const { return num_vals; }

        void set_probability (
            unsigned long value,
            const assignment& ps,
            double p
        )
        {
            // make sure requires clause is not broken
            DLIB_ASSERT( value < num_values() && 0.0 <= p && p <= 1.0 ,
                         "\tvoid conditional_probability_table::set_probability()"
                         << "\n\tinvalid arguments to set_probability"
                         << "\n\tvalue: " << value
                         << "\n\tnum_values(): " << num_values()
                         << "\n\tp:     " << p
                         << "\n\tps:    " << ps
                         << "\n\tthis:  " << this
            );

            if (table.is_in_domain(ps))
            {
                table[ps](value) = p;
            }
            else
            {
                matrix<double,1> dist(num_vals);
                set_all_elements(dist,-1);
                dist(value) = p;
                assignment temp(ps);
                table.add(temp,dist);
            }
        }

        double probability(
            unsigned long value,
            const assignment& ps
        ) const
        {
            // make sure requires clause is not broken
            DLIB_ASSERT( value < num_values() && has_entry_for(value,ps) ,
                         "\tvoid conditional_probability_table::probability()"
                         << "\n\tinvalid arguments to probability"
                         << "\n\tvalue:        " << value
                         << "\n\tnum_values(): " << num_values()
                         << "\n\tps:           " << ps
                         << "\n\tthis:         " << this
            );

            return table[ps](value);
        }

        void clear()
        {
            table.clear();
            num_vals = 0;
        }

        void empty_table ()
        {
            table.clear();
        }

        void swap (
            conditional_probability_table& item
        )
        {
            exchange(num_vals, item.num_vals);
            table.swap(item.table);
        }

        friend inline void serialize (
            const conditional_probability_table& item,
            std::ostream& out
        )
        {
            serialize(item.table, out);
            serialize(item.num_vals, out);
        }

        friend inline void deserialize (
            conditional_probability_table& item,
            std::istream& in
        )
        {
            deserialize(item.table, in);
            deserialize(item.num_vals, in);
        }

    private:
        dlib::map<assignment, matrix<double,1> >::kernel_1b_c table;
        unsigned long num_vals;
    };

    inline void swap (
        conditional_probability_table& a,
        conditional_probability_table& b
    ) { a.swap(b); }

// ------------------------------------------------------------------------

    class bayes_node : noncopyable
    {
    public:
        bayes_node ()
        {
            is_instantiated = false;
            value_ = 0;
        }

        unsigned long value (
        ) const { return value_;}

        void set_value (
            unsigned long new_value
        )
        {
            // make sure requires clause is not broken
            DLIB_ASSERT( new_value < table().num_values(),
                         "\tvoid bayes_node::set_value(new_value)"
                         << "\n\tnew_value must be less than the number of possible values for this node"
                         << "\n\tnew_value:            " << new_value
                         << "\n\ttable().num_values(): " << table().num_values()
                         << "\n\tthis:                 " << this
            );

            value_ = new_value;
        }

        conditional_probability_table& table (
        ) { return table_; }

        const conditional_probability_table& table (
        ) const { return table_; }

        bool is_evidence (
        ) const { return is_instantiated; }

        void set_as_nonevidence (
        ) { is_instantiated = false; }

        void set_as_evidence (
        ) { is_instantiated = true; }

        void swap (
            bayes_node& item
        )
        {
            exchange(value_, item.value_);
            exchange(is_instantiated, item.is_instantiated);
            table_.swap(item.table_);
        }

        friend inline void serialize (
            const bayes_node& item,
            std::ostream& out
        )
        {
            serialize(item.value_, out);
            serialize(item.is_instantiated, out);
            serialize(item.table_, out);
        }

        friend inline void deserialize (
            bayes_node& item,
            std::istream& in
        )
        {
            deserialize(item.value_, in);
            deserialize(item.is_instantiated, in);
            deserialize(item.table_, in);
        }

    private:

        unsigned long value_;
        bool is_instantiated;
        conditional_probability_table table_;
    };

    inline void swap (
        bayes_node& a,
        bayes_node& b
    ) { a.swap(b); }

// ------------------------------------------------------------------------

    namespace bayes_node_utils
    {

        template <typename T>
        unsigned long node_num_values (
            const T& bn,
            unsigned long n
        )
        {
            // make sure requires clause is not broken
            DLIB_ASSERT( n < bn.number_of_nodes(),
                         "\tvoid bayes_node_utils::node_num_values(bn, n)"
                         << "\n\tInvalid arguments to this function"
                         << "\n\tn:                     " << n
                         << "\n\tbn.number_of_nodes():  " << bn.number_of_nodes()
            );

            return bn.node(n).data.table().num_values();
        }

    // ----------------------------------------------------------------------------------------

        template <typename T>
        void set_node_value (
            T& bn,
            unsigned long n,
            unsigned long val
        )
        {
            // make sure requires clause is not broken
            DLIB_ASSERT( n < bn.number_of_nodes() && val < node_num_values(bn,n),
                         "\tvoid bayes_node_utils::set_node_value(bn, n, val)"
                         << "\n\tInvalid arguments to this function"
                         << "\n\tn:                     " << n
                         << "\n\tval:                   " << val
                         << "\n\tbn.number_of_nodes():  " << bn.number_of_nodes()
                         << "\n\tnode_num_values(bn,n): " << node_num_values(bn,n)
            );

            bn.node(n).data.set_value(val);
        }

    // ----------------------------------------------------------------------------------------
        template <typename T>
        unsigned long node_value (
            const T& bn,
            unsigned long n
        )
        {
            // make sure requires clause is not broken
            DLIB_ASSERT( n < bn.number_of_nodes(),
                         "\tunsigned long bayes_node_utils::node_value(bn, n)"
                         << "\n\tInvalid arguments to this function"
                         << "\n\tn:                     " << n
                         << "\n\tbn.number_of_nodes():  " << bn.number_of_nodes()
            );

            return bn.node(n).data.value();
        }
    // ----------------------------------------------------------------------------------------

        template <typename T>
        bool node_is_evidence (
            const T& bn,
            unsigned long n
        )
        {
            // make sure requires clause is not broken
            DLIB_ASSERT( n < bn.number_of_nodes(),
                         "\tbool bayes_node_utils::node_is_evidence(bn, n)"
                         << "\n\tInvalid arguments to this function"
                         << "\n\tn:                     " << n
                         << "\n\tbn.number_of_nodes():  " << bn.number_of_nodes()
            );

            return bn.node(n).data.is_evidence();
        }

    // ----------------------------------------------------------------------------------------

        template <typename T>
        void set_node_as_evidence (
            T& bn,
            unsigned long n
        )
        {
            // make sure requires clause is not broken
            DLIB_ASSERT( n < bn.number_of_nodes(),
                         "\tvoid bayes_node_utils::set_node_as_evidence(bn, n)"
                         << "\n\tInvalid arguments to this function"
                         << "\n\tn:                     " << n
                         << "\n\tbn.number_of_nodes():  " << bn.number_of_nodes()
            );

            bn.node(n).data.set_as_evidence();
        }

    // ----------------------------------------------------------------------------------------
        template <typename T>
        void set_node_as_nonevidence (
            T& bn,
            unsigned long n
        )
        {
            // make sure requires clause is not broken
            DLIB_ASSERT( n < bn.number_of_nodes(),
                         "\tvoid bayes_node_utils::set_node_as_nonevidence(bn, n)"
                         << "\n\tInvalid arguments to this function"
                         << "\n\tn:                     " << n
                         << "\n\tbn.number_of_nodes():  " << bn.number_of_nodes()
            );

            bn.node(n).data.set_as_nonevidence();
        }

    // ----------------------------------------------------------------------------------------

        template <typename T>
        void set_node_num_values (
            T& bn,
            unsigned long n,
            unsigned long num
        )
        {
            // make sure requires clause is not broken
            DLIB_ASSERT( n < bn.number_of_nodes(),
                         "\tvoid bayes_node_utils::set_node_num_values(bn, n, num)"
                         << "\n\tInvalid arguments to this function"
                         << "\n\tn:                     " << n
                         << "\n\tbn.number_of_nodes():  " << bn.number_of_nodes()
            );

            bn.node(n).data.table().set_num_values(num);
        }

    // ----------------------------------------------------------------------------------------

        template <typename T>
        double node_probability (
            const T& bn,
            unsigned long n,
            unsigned long value,
            const assignment& parents
        )
        {
            // make sure requires clause is not broken
            DLIB_ASSERT( n < bn.number_of_nodes() && value < node_num_values(bn,n),
                         "\tdouble bayes_node_utils::node_probability(bn, n, value, parents)"
                         << "\n\tInvalid arguments to this function"
                         << "\n\tn:                     " << n
                         << "\n\tvalue:                 " << value
                         << "\n\tbn.number_of_nodes():  " << bn.number_of_nodes()
                         << "\n\tnode_num_values(bn,n): " << node_num_values(bn,n)
            );

            DLIB_ASSERT( parents.size() == bn.node(n).number_of_parents(),
                         "\tdouble bayes_node_utils::node_probability(bn, n, value, parents)"
                         << "\n\tInvalid arguments to this function"
                         << "\n\tn:                             " << n
                         << "\n\tparents.size():                " << parents.size()
                         << "\n\tb.node(n).number_of_parents(): " << bn.node(n).number_of_parents()
            );

#ifdef ENABLE_ASSERTS
            parents.reset();
            while (parents.move_next())
            {
                const unsigned long x = parents.element().key();
                DLIB_ASSERT( bn.has_edge(x, n),
                             "\tdouble bayes_node_utils::node_probability(bn, n, value, parents)"
                             << "\n\tInvalid arguments to this function"
                             << "\n\tn: " << n
                             << "\n\tx: " << x
                );
                DLIB_ASSERT( parents[x] < node_num_values(bn,x),
                             "\tdouble bayes_node_utils::node_probability(bn, n, value, parents)"
                             << "\n\tInvalid arguments to this function"
                             << "\n\tn:                     " << n
                             << "\n\tx:                     " << x
                             << "\n\tparents[x]:            " << parents[x]
                             << "\n\tnode_num_values(bn,x): " << node_num_values(bn,x)
                );
            }
#endif

            return bn.node(n).data.table().probability(value, parents);
        }

    // ----------------------------------------------------------------------------------------

        template <typename T>
        void set_node_probability (
            T& bn,
            unsigned long n,
            unsigned long value,
            const assignment& parents,
            double p
        )
        {
            // make sure requires clause is not broken
            DLIB_ASSERT( n < bn.number_of_nodes() && value < node_num_values(bn,n),
                         "\tvoid bayes_node_utils::set_node_probability(bn, n, value, parents, p)"
                         << "\n\tInvalid arguments to this function"
                         << "\n\tn:                     " << n
                         << "\n\tp:                     " << p
                         << "\n\tvalue:                 " << value
                         << "\n\tbn.number_of_nodes():  " << bn.number_of_nodes()
                         << "\n\tnode_num_values(bn,n): " << node_num_values(bn,n)
            );

            DLIB_ASSERT( parents.size() == bn.node(n).number_of_parents(),
                         "\tvoid bayes_node_utils::set_node_probability(bn, n, value, parents, p)"
                         << "\n\tInvalid arguments to this function"
                         << "\n\tn:                             " << n
                         << "\n\tp:                             " << p
                         << "\n\tparents.size():                " << parents.size()
                         << "\n\tbn.node(n).number_of_parents(): " << bn.node(n).number_of_parents()
            );

            DLIB_ASSERT( 0.0 <= p && p <= 1.0,
                         "\tvoid bayes_node_utils::set_node_probability(bn, n, value, parents, p)"
                         << "\n\tInvalid arguments to this function"
                         << "\n\tn: " << n
                         << "\n\tp: " << p
            );

#ifdef ENABLE_ASSERTS
            parents.reset();
            while (parents.move_next())
            {
                const unsigned long x = parents.element().key();
                DLIB_ASSERT( bn.has_edge(x, n),
                             "\tvoid bayes_node_utils::set_node_probability(bn, n, value, parents, p)"
                             << "\n\tInvalid arguments to this function"
                             << "\n\tn: " << n
                             << "\n\tx: " << x
                );
                DLIB_ASSERT( parents[x] < node_num_values(bn,x),
                             "\tvoid bayes_node_utils::set_node_probability(bn, n, value, parents, p)"
                             << "\n\tInvalid arguments to this function"
                             << "\n\tn:                     " << n
                             << "\n\tx:                     " << x
                             << "\n\tparents[x]:            " << parents[x]
                             << "\n\tnode_num_values(bn,x): " << node_num_values(bn,x)
                );
            }
#endif

            bn.node(n).data.table().set_probability(value,parents,p);
        }

// ----------------------------------------------------------------------------------------

        template <typename T>
        const assignment node_first_parent_assignment (
            const T& bn,
            unsigned long n
        )
        {
            // make sure requires clause is not broken
            DLIB_ASSERT( n < bn.number_of_nodes(),
                         "\tconst assignment bayes_node_utils::node_first_parent_assignment(bn, n)"
                         << "\n\tInvalid arguments to this function"
                         << "\n\tn:                     " << n
            );

            assignment a;
            const unsigned long num_parents = bn.node(n).number_of_parents();
            for (unsigned long i = 0; i < num_parents; ++i)
            {
                a.add(bn.node(n).parent(i).index(), 0);
            }
            return a;
        }

// ----------------------------------------------------------------------------------------

        template <typename T>
        bool node_next_parent_assignment (
            const T& bn,
            unsigned long n,
            assignment& a
        )
        {
            // make sure requires clause is not broken
            DLIB_ASSERT( n < bn.number_of_nodes(),
                         "\tbool bayes_node_utils::node_next_parent_assignment(bn, n, a)"
                         << "\n\tInvalid arguments to this function"
                         << "\n\tn:                     " << n
            );

            DLIB_ASSERT( a.size() == bn.node(n).number_of_parents(),
                         "\tbool bayes_node_utils::node_next_parent_assignment(bn, n, a)"
                         << "\n\tInvalid arguments to this function"
                         << "\n\tn:                             " << n
                         << "\n\ta.size():                      " << a.size()
                         << "\n\tbn.node(n).number_of_parents(): " << bn.node(n).number_of_parents()
            );

#ifdef ENABLE_ASSERTS
            a.reset();
            while (a.move_next())
            {
                const unsigned long x = a.element().key();
                DLIB_ASSERT( bn.has_edge(x, n),
                             "\tbool bayes_node_utils::node_next_parent_assignment(bn, n, a)"
                             << "\n\tInvalid arguments to this function"
                             << "\n\tn: " << n
                             << "\n\tx: " << x
                );
                DLIB_ASSERT( a[x] < node_num_values(bn,x),
                             "\tbool bayes_node_utils::node_next_parent_assignment(bn, n, a)"
                             << "\n\tInvalid arguments to this function"
                             << "\n\tn:                     " << n
                             << "\n\tx:                     " << x
                             << "\n\ta[x]:                  " << a[x]
                             << "\n\tnode_num_values(bn,x): " << node_num_values(bn,x)
                );
            }
#endif

            // basically this loop just adds 1 to the assignment but performs
            // carries if necessary
            for (unsigned long p = 0; p < a.size(); ++p)
            {
                const unsigned long pindex = bn.node(n).parent(p).index();
                a[pindex] += 1;

                // if we need to perform a carry
                if (a[pindex] >= node_num_values(bn,pindex))
                {
                    a[pindex] = 0;
                }
                else
                {
                    // no carry necessary so we are done
                    return true;
                }
            }

            // we got through the entire loop which means a carry propagated all the way out
            // so there must not be any more valid assignments left
            return false;
        }

// ----------------------------------------------------------------------------------------

        template <typename T>
        bool node_cpt_filled_out (
            const T& bn,
            unsigned long n
        )
        {
            // make sure requires clause is not broken
            DLIB_ASSERT( n < bn.number_of_nodes(),
                         "\tbool bayes_node_utils::node_cpt_filled_out(bn, n)"
                         << "\n\tInvalid arguments to this function"
                         << "\n\tn:                     " << n
                         << "\n\tbn.number_of_nodes():  " << bn.number_of_nodes()
            );

            const unsigned long num_values = node_num_values(bn,n);

            const conditional_probability_table& table = bn.node(n).data.table();

            // now loop over all the possible parent assignments for this node
            assignment a(node_first_parent_assignment(bn,n));
            do
            {
                double sum = 0;
                // make sure that this assignment has an entry for all the values this node can take one
                for (unsigned long value = 0; value < num_values; ++value)
                {
                    if (table.has_entry_for(value,a) == false)
                        return false;
                    else
                        sum += table.probability(value,a);
                }

                // check if the sum of probabilities equals 1 as it should
                if (std::abs(sum-1.0) > 1e-5)
                    return false;
            } while (node_next_parent_assignment(bn,n,a));

            return true;
        }

    }

// ----------------------------------------------------------------------------------------

    class bayesian_network_gibbs_sampler : noncopyable
    {
    public:

        bayesian_network_gibbs_sampler ()
        {
            rnd.set_seed(cast_to_string(std::time(0)));
        }

        template <
            typename T
            >
        void sample_graph (
            T& bn
        )
        {
            using namespace bayes_node_utils;
            for (unsigned long n = 0; n < bn.number_of_nodes(); ++n)
            {
                if (node_is_evidence(bn, n))
                    continue;

                samples.set_size(node_num_values(bn,n));
                // obtain the probability distribution for this node
                for (long i = 0; i < samples.nc(); ++i)
                {
                    set_node_value(bn, n, i);
                    samples(i) = node_probability(bn, n);

                    for (unsigned long j = 0; j < bn.node(n).number_of_children(); ++j)
                        samples(i) *= node_probability(bn, bn.node(n).child(j).index());
                }

                //normalize samples
                samples /= sum(samples);

                // select a random point in the probability distribution
                double prob = rnd.get_random_double();

                // now find the point in the distribution this probability corresponds to
                long j;
                for (j = 0; j < samples.nc()-1; ++j)
                {
                    if (prob <= samples(j))
                        break;
                    else
                        prob -= samples(j);
                }

                set_node_value(bn, n, j);
            }
        }

    private:

        template <
            typename T
            >
        double node_probability (
            const T& bn,
            unsigned long n
        )
        /*!
            requires
                - n < bn.number_of_nodes()
            ensures
                - computes the probability of node n having its current value given
                  the current values of its parents in the network bn
        !*/
        {
            v.clear();
            for (unsigned long i = 0; i < bn.node(n).number_of_parents(); ++i)
            {
                v.add(bn.node(n).parent(i).index(), bn.node(n).parent(i).data.value());
            }
            return bn.node(n).data.table().probability(bn.node(n).data.value(), v);
        }

        assignment v;

        dlib::rand rnd;
        matrix<double,1> samples;
    };

// ----------------------------------------------------------------------------------------

    namespace bayesian_network_join_tree_helpers
    {
        class bnjt
        {
            /*!
                this object is the base class used in this pimpl idiom
            !*/
        public:
            virtual ~bnjt() {}

            virtual const matrix<double,1> probability(
                unsigned long idx
            )  const = 0;
        };

        template <typename T, typename U>
        class bnjt_impl : public bnjt
        {
            /*!
                This object is the implementation in the pimpl idiom
            !*/

        public:

            bnjt_impl (
                const T& bn,
                const U& join_tree
            )
            {
                create_bayesian_network_join_tree(bn, join_tree, join_tree_values);

                cliques.resize(bn.number_of_nodes());

                // figure out which cliques contain each node
                for (unsigned long i = 0; i < cliques.size(); ++i)
                {
                    // find the smallest clique that contains node with index i
                    unsigned long smallest_clique = 0;
                    unsigned long size = std::numeric_limits<unsigned long>::max();

                    for (unsigned long n = 0; n < join_tree.number_of_nodes(); ++n)
                    {
                        if (join_tree.node(n).data.is_member(i) && join_tree.node(n).data.size() < size)
                        {
                            size = join_tree.node(n).data.size();
                            smallest_clique = n;
                        }
                    }

                    cliques[i] = smallest_clique;
                }
            }

            virtual const matrix<double,1> probability(
                unsigned long idx
            ) const
            {
                join_tree_values.node(cliques[idx]).data.marginalize(idx, table);
                table.normalize();
                var.clear();
                var.add(idx);
                dist.set_size(table.size());

                // read the probabilities out of the table and into the row matrix
                for (unsigned long i = 0; i < table.size(); ++i)
                {
                    var[idx] = i;
                    dist(i) = table.probability(var);
                }

                return dist;
            }

        private:

            graph< joint_probability_table, joint_probability_table >::kernel_1a_c join_tree_values;
            array<unsigned long> cliques;
            mutable joint_probability_table table;
            mutable assignment var;
            mutable matrix<double,1> dist;

        // ----------------------------------------------------------------------------------------

            template <typename set_type, typename node_type>
            bool set_contains_all_parents_of_node (
                const set_type& set,
                const node_type& node
            )
            {
                for (unsigned long i = 0; i < node.number_of_parents(); ++i)
                {
                    if (set.is_member(node.parent(i).index()) == false)
                        return false;
                }
                return true;
            }

        // ----------------------------------------------------------------------------------------

            template <
                typename V
                >
            void pass_join_tree_message (
                const U& join_tree,
                V& bn_join_tree ,
                unsigned long from,
                unsigned long to
            )
            {
                using namespace bayes_node_utils;
                const typename U::edge_type& e = edge(join_tree, from, to);
                typename V::edge_type& old_s = edge(bn_join_tree, from, to);

                typedef typename V::edge_type joint_prob_table;

                joint_prob_table new_s;
                bn_join_tree.node(from).data.marginalize(e, new_s);

                joint_probability_table temp(new_s);
                // divide new_s by old_s and store the result in temp.
                // if old_s is empty then that is the same as if it was all 1s
                // so we don't have to do this if that is the case.
                if (old_s.size() > 0)
                {
                    temp.reset();
                    old_s.reset();
                    while (temp.move_next())
                    {
                        old_s.move_next();
                        if (old_s.element().value() != 0)
                            temp.element().value()  /= old_s.element().value();
                    }
                }

                // now multiply temp by d and store the results in d
                joint_probability_table& d = bn_join_tree.node(to).data;
                d.reset();
                while (d.move_next())
                {
                    assignment a;
                    const assignment& asrc = d.element().key();
                    asrc.reset();
                    while (asrc.move_next())
                    {
                        if (e.is_member(asrc.element().key()))
                            a.add(asrc.element().key(), asrc.element().value());
                    }

                    d.element().value() *= temp.probability(a);

                }

                // store new_s in old_s
                new_s.swap(old_s);

            }

        // ----------------------------------------------------------------------------------------

            template <
                typename V
                >
            void create_bayesian_network_join_tree (
                const T& bn,
                const U& join_tree,
                V& bn_join_tree
            )
            /*!
                requires
                    - bn is a proper bayesian network
                    - join_tree is the join tree for that bayesian network
                ensures
                    - bn_join_tree == the output of the join tree algorithm for bayesian network inference.
                      So each node in this graph contains a joint_probability_table for the clique
                      in the corresponding node in the join_tree graph.
            !*/
            {
                using namespace bayes_node_utils;
                bn_join_tree.clear();
                copy_graph_structure(join_tree, bn_join_tree);

                // we need to keep track of which node is "in" each clique for the purposes of
                // initializing the tables in each clique.  So this vector will be used to do that
                // and a value of join_tree.number_of_nodes() means that the node with
                // that index is unassigned.
                std::vector<unsigned long> node_assigned_to(bn.number_of_nodes(),join_tree.number_of_nodes());

                // populate evidence with all the evidence node indices and their values
                dlib::map<unsigned long, unsigned long>::kernel_1b_c evidence;
                for (unsigned long i = 0; i < bn.number_of_nodes(); ++i)
                {
                    if (node_is_evidence(bn, i))
                    {
                        unsigned long idx = i;
                        unsigned long value = node_value(bn, i);
                        evidence.add(idx,value);
                    }
                }

                // initialize the bn join tree
                for (unsigned long i = 0; i < join_tree.number_of_nodes(); ++i)
                {
                    bool contains_evidence = false;
                    std::vector<unsigned long> indices;
                    assignment value;

                    // loop over all the nodes in this clique in the join tree.  In this loop
                    // we are making an assignment with all the values of the nodes it represents set to 0
                    join_tree.node(i).data.reset();
                    while (join_tree.node(i).data.move_next())
                    {
                        const unsigned long idx = join_tree.node(i).data.element();
                        indices.push_back(idx);
                        value.add(idx);

                        if (evidence.is_in_domain(join_tree.node(i).data.element()))
                            contains_evidence = true;
                    }

                    // now loop over all possible combinations of values that the nodes this
                    // clique in the join tree can take on.  We do this by counting by one through all
                    // legal values
                    bool more_assignments = true;
                    while (more_assignments)
                    {
                        bn_join_tree.node(i).data.set_probability(value,1);

                        // account for any evidence
                        if (contains_evidence)
                        {
                            // loop over all the nodes in this cluster
                            for (unsigned long j = 0; j < indices.size(); ++j)
                            {
                                // if the current node is an evidence node
                                if (evidence.is_in_domain(indices[j]))
                                {
                                    const unsigned long idx = indices[j];
                                    const unsigned long evidence_value = evidence[idx];
                                    if (value[idx] != evidence_value)
                                        bn_join_tree.node(i).data.set_probability(value , 0);
                                }
                            }
                        }

                        // now check if any of the nodes in this cluster also have their parents in this cluster
                        join_tree.node(i).data.reset();
                        while (join_tree.node(i).data.move_next())
                        {
                            const unsigned long idx = join_tree.node(i).data.element();
                            // if this clique contains all the parents of this node and also hasn't
                            // been assigned to another clique
                            if (set_contains_all_parents_of_node(join_tree.node(i).data,  bn.node(idx)) &&
                                (i == node_assigned_to[idx] || node_assigned_to[idx] == join_tree.number_of_nodes()) )
                            {
                                // note that this node is now assigned to this clique
                                node_assigned_to[idx] = i;
                                // node idx has all its parents in the cluster
                                assignment parent_values;
                                for (unsigned long j = 0; j < bn.node(idx).number_of_parents(); ++j)
                                {
                                    const unsigned long pidx = bn.node(idx).parent(j).index();
                                    parent_values.add(pidx, value[pidx]);
                                }

                                double temp = bn_join_tree.node(i).data.probability(value);
                                bn_join_tree.node(i).data.set_probability(value, temp * node_probability(bn, idx, value[idx], parent_values));

                            }
                        }

                        // now advance the value variable to its next possible state if there is one
                        more_assignments = false;
                        value.reset();
                        while (value.move_next())
                        {
                            value.element().value() += 1;
                            // if overflow
                            if (value.element().value() == node_num_values(bn, value.element().key()))
                            {
                                value.element().value() = 0;
                            }
                            else
                            {
                                more_assignments = true;
                                break;
                            }
                        }

                    } // end while (more_assignments)
                }

                // the tree is now initialized.  Now all we need to do is perform the propagation and
                // we are done
                dlib::array<dlib::set<unsigned long>::compare_1b_c> remaining_msg_to_send;
                dlib::array<dlib::set<unsigned long>::compare_1b_c> remaining_msg_to_receive;
                remaining_msg_to_receive.resize(join_tree.number_of_nodes());
                remaining_msg_to_send.resize(join_tree.number_of_nodes());
                for (unsigned long i = 0; i < remaining_msg_to_receive.size(); ++i)
                {
                    for (unsigned long j = 0; j < join_tree.node(i).number_of_neighbors(); ++j)
                    {
                        const unsigned long idx = join_tree.node(i).neighbor(j).index();
                        unsigned long temp;
                        temp = idx; remaining_msg_to_receive[i].add(temp);
                        temp = idx; remaining_msg_to_send[i].add(temp);
                    }
                }

                // now remaining_msg_to_receive[i] contains all the nodes that node i hasn't yet received
                // a message from.
                // we will consider node 0 to be the root node.

                bool message_sent = true;
                std::vector<unsigned long>::iterator iter;
                while (message_sent)
                {
                    message_sent = false;
                    for (unsigned long i = 1; i < remaining_msg_to_send.size(); ++i)
                    {
                        // if node i hasn't sent any messages but has received all but one then send a message to the one
                        // node who hasn't sent i a message
                        if (remaining_msg_to_send[i].size() == join_tree.node(i).number_of_neighbors() && remaining_msg_to_receive[i].size() == 1)
                        {
                            unsigned long to;
                            // get the last remaining thing from this set
                            remaining_msg_to_receive[i].remove_any(to);

                            // send the message
                            pass_join_tree_message(join_tree, bn_join_tree, i, to);

                            // record that we sent this message
                            remaining_msg_to_send[i].destroy(to);
                            remaining_msg_to_receive[to].destroy(i);

                            // put to back in since we still need to receive it
                            remaining_msg_to_receive[i].add(to);
                            message_sent = true;
                        }
                        else if (remaining_msg_to_receive[i].size() == 0 && remaining_msg_to_send[i].size() > 0)
                        {
                            unsigned long to;
                            remaining_msg_to_send[i].remove_any(to);
                            remaining_msg_to_receive[to].destroy(i);
                            pass_join_tree_message(join_tree, bn_join_tree, i, to);
                            message_sent = true;
                        }
                    }

                    if (remaining_msg_to_receive[0].size() == 0)
                    {
                        // send a message to all of the root nodes neighbors unless we have already sent out he messages
                        while (remaining_msg_to_send[0].size() > 0)
                        {
                            unsigned long to;
                            remaining_msg_to_send[0].remove_any(to);
                            remaining_msg_to_receive[to].destroy(0);
                            pass_join_tree_message(join_tree, bn_join_tree, 0, to);
                            message_sent = true;
                        }
                    }

                }

            }

        };
    }

    class bayesian_network_join_tree : noncopyable
    {
        /*!
            use the pimpl idiom to push the template arguments from the class level to the
            constructor level
        !*/

    public:

        template <
            typename T,
            typename U
            >
        bayesian_network_join_tree (
            const T& bn,
            const U& join_tree
        )
        {
            // make sure requires clause is not broken
            DLIB_ASSERT( bn.number_of_nodes() > 0 ,
                        "\tbayesian_network_join_tree::bayesian_network_join_tree(bn,join_tree)"
                        << "\n\tYou have given an invalid bayesian network"
                        << "\n\tthis:              " << this
                    );

            DLIB_ASSERT( is_join_tree(bn, join_tree) == true ,
                        "\tbayesian_network_join_tree::bayesian_network_join_tree(bn,join_tree)"
                        << "\n\tYou have given an invalid join tree for the supplied bayesian network"
                        << "\n\tthis:              " << this
                    );
            DLIB_ASSERT( graph_contains_length_one_cycle(bn) == false,
                        "\tbayesian_network_join_tree::bayesian_network_join_tree(bn,join_tree)"
                        << "\n\tYou have given an invalid bayesian network"
                        << "\n\tthis:              " << this
                    );
            DLIB_ASSERT( graph_is_connected(bn) == true,
                        "\tbayesian_network_join_tree::bayesian_network_join_tree(bn,join_tree)"
                        << "\n\tYou have given an invalid bayesian network"
                        << "\n\tthis:              " << this
                    );

#ifdef ENABLE_ASSERTS
            for (unsigned long i = 0; i < bn.number_of_nodes(); ++i)
            {
                DLIB_ASSERT(bayes_node_utils::node_cpt_filled_out(bn,i) == true,
                        "\tbayesian_network_join_tree::bayesian_network_join_tree(bn,join_tree)"
                        << "\n\tYou have given an invalid bayesian network. "
                        << "\n\tYou must finish filling out the conditional_probability_table of node " << i
                        << "\n\tthis:              " << this
                    );
            }
#endif

            impl.reset(new bayesian_network_join_tree_helpers::bnjt_impl<T,U>(bn, join_tree));
            num_nodes = bn.number_of_nodes();
        }

        const matrix<double,1> probability(
            unsigned long idx
        ) const
        {
            // make sure requires clause is not broken
            DLIB_ASSERT( idx < number_of_nodes() ,
                        "\tconst matrix<double,1> bayesian_network_join_tree::probability(idx)"
                        << "\n\tYou have specified an invalid node index"
                        << "\n\tidx:               " << idx
                        << "\n\tnumber_of_nodes(): " << number_of_nodes()
                        << "\n\tthis:              " << this
                    );

            return impl->probability(idx);
        }

        unsigned long number_of_nodes (
        ) const { return num_nodes; }

        void swap (
            bayesian_network_join_tree& item
        )
        {
            exchange(num_nodes, item.num_nodes);
            impl.swap(item.impl);
        }

    private:

        scoped_ptr<bayesian_network_join_tree_helpers::bnjt> impl;
        unsigned long num_nodes;

    };

    inline void swap (
        bayesian_network_join_tree& a,
        bayesian_network_join_tree& b
    ) { a.swap(b); }

}

// ----------------------------------------------------------------------------------------

#endif // DLIB_BAYES_UTILs_


text:
package bosh

import (
	. "github.com/onsi/gomega"
	"github.com/vito/cmdtest"
	"github.com/vito/cmdtest/matchers"

	"os"
	"strings"
)

func BoshDeleteRelease() {
	result := BoshCombinedOutput("-n", "delete", "release", "bosh-aws-tools")
	Expect(result).To(cmdtest_matchers.SayBranches(
		cmdtest.ExpectBranch{
			Pattern:  "Deleted",
			Callback: func() {},
		},
		cmdtest.ExpectBranch{
			Pattern:  "doesn't exist", // already clean
			Callback: func() {},
		},
	))
}

func BoshCreateRelease() {
	result := BoshInDir(projectDir(), "create", "release", "--force")
	Expect(result).To(cmdtest_matchers.Say("Release manifest:"))
}

func BoshUploadRelease() {
	// Make sure it uploads new release since we cannot rely
	// on already uploaded release having the same bits
	// as the newly created release (even if their versions match)
	result := BoshInDir(projectDir(), "-n", "upload", "release")
	Expect(result).To(cmdtest_matchers.Say("Release uploaded"))
}

func projectDir() string {
	cwd, err := os.Getwd()
	if err != nil {
		panic(err)
	}

	return strings.Split(cwd, "/test")[0]
}

redpajama_set_name: RedPajamaGithub


text:
import ZTabs from './ZTabs'
import ZTabPane from './ZTabPane'
import ZTabBar from './ZTabBar'
export {
  ZTabs,
  ZTabPane,
  ZTabBar
}


text:
sap.m.MultiComboBox.extend("org.scn.community.databound.MultiComboBox", {

	setData : function(value) {
		this._data = value;
		return this;
	},

	getData : function(value) {
		return this._data;
	},

	metadata: {
        properties: {
              "bound": {type: "string"},
              "DDimension": {type: "string"},
              "DSelectedKey": {type: "string"},
              "DSelectedText": {type: "string"},
              "DSelectedKeyBexReady" : {type: "string"},
              "DSorting": {type: "string"},
              "DSortingDirection": {type: "string"},
              "DSkipResultRow": {type: "boolean"},
              "DSelectAllText": {type: "string"},
              "DSelectNoText": {type: "string"},
              "DItemList": {type: "string"},
              "DPropFileUrl": {type: "string"},
              "DEnabled": {type: "boolean"},
              "DTooltip": {type: "string"}
        }
	},

	initDesignStudio: function() {
		var that = this;
		//add default css class to be assigned with the combobox. That way you can override specific layout more gracefully.
		this.addStyleClass('scn-pack-multiComboBox');
		//i18n text identifiers
		this.placeholderTextIdentifier = "scn-multicombobox-placeholderText";
		//identify language dynamically
		this.sCurrentLocale = sap.ui.getCore().getConfiguration().getLanguage();
		//make sure default value applies even if no i18n properties file is loaded!
		this.placeholderTextLocalized = "choose value...";

//		// Create JSON data model
//		var mData = {
//				  selected: ["0","1"],
//				  items:[
//				    {key:"0",text:"first"},
//				    {key:"1",text:"second"},
//				    {key:"2",text:"third"},
//				    {key:"3",text:"fourth"}
//				  ]
//				};
		this._oModel = new sap.ui.model.json.JSONModel();
		//check https://scn.sap.com/thread/3784288 or https://github.com/SAP/openui5/issues/927
		this._oModel.setSizeLimit(1000);

		sap.ui.getCore().setModel(this._oModel);
		this.setModel(this._oModel);

		this.bindProperty("tooltip", "/tooltip");
		this.bindProperty("editable", "/editable");

		var oItemTemplate = new sap.ui.core.Item();
		oItemTemplate.bindProperty("text", "text");
		oItemTemplate.bindProperty("key", "key");
		oItemTemplate.bindProperty("tooltip", "text");
		this.bindItems("/items", oItemTemplate); //That doesn't work according to https://github.com/SAP/openui5/issues/121
		//workaround for bindItems according to https://github.com/SAP/openui5/issues/121
//		this.bindAggregation('items', '/items', oItemTemplate);

		//This event handler doesn't fire properly on IE and firefox. Therefore logic ported to onChange. Unfortunately the popover needs to be opened on every selection
		var onSelectionFinish = function(oControlEvent) {
			var selection = oControlEvent.getParameter("selectedItems");
			var keys = [];
			var texts = [];
			for(var i=0;i<selection.length;i++){
				keys.push(selection[i].getKey());
				texts.push(selection[i].getText());
			}
			//get values bex variable ready (has to be seperated by semicolons!)
			var keysBexReady = JSON.stringify(keys)
			keysBexReady = keysBexReady.substring(2,keysBexReady.length-2);
			keysBexReady = this.replaceAll(keysBexReady,",",";")
			keysBexReady = this.replaceAll(keysBexReady,'"',"");
			this.setDSelectedKey(keys);
			this.setDSelectedText(texts);
			this.setDSelectedKeyBexReady(keysBexReady);

			that.fireDesignStudioPropertiesChanged(["DSelectedKey", "DSelectedText", "DSelectedKeyBexReady"]);
			that.fireDesignStudioEvent("onSelectionFinished");
		};

		var onChange = function(oControlEvent){
			var selection = oControlEvent.getParameter("changedItem").getText();

			if(selection === this.getDSelectAllText()){
				var items = this._oModel.oData.items;
				var selectedKeys = [];
				for(var i=0;i<items.length;i++){
					if(items[i].key !== "ALL" && items[i].key !== "CLEAR"){
						selectedKeys.push(items[i].key);
					}
				}
				//assign every key to be marked as selected
				this.setSelectedKeys(selectedKeys);

			}else if(selection === this.getDSelectNoText()){

				//assign every key to be marked as not selected
				this.setSelectedKeys([]);
			}
			that.fireDesignStudioEvent("onChange");
		};
		this.attachSelectionChange(onChange);
		this.attachSelectionFinish(onSelectionFinish);

		this.setPlaceholder(this.placeholderTextLocalized);
		this.DItemList = [];

//		$('div[class*="sapMMultiComboBoxList"]').focusout(function() {
//			$(".sapMComboBoxBaseArrow").click();
//		});

//		org_scn_community_basics.resizeContentAbsoluteLayout(that, $(that).find("div"), this.onResize);
	},

	renderer: {},

	afterDesignStudioUpdate: function() {
		var oBundle = null;
		var path = this.getDPropFileUrl();
		//If no URL is provided, fallback text is used
		if(path !== "" && path !== null){
			//load language dependent translations
			oBundle = jQuery.sap.resources({url : path, locale: this.sCurrentLocale});
			this.placeholderTextLocalized = oBundle.getText(this.placeholderTextIdentifier);
			this.setPlaceholder(this.placeholderTextLocalized);
		}

		this.setEnabled(this.getDEnabled());

		//make sure of showing formerly selected items when afterUpdate gets triggered from another context
//		var t = this.getSelectedKeys();
		var selectedKeys = this.getProperty('DSelectedKey');
		var keys = selectedKeys.split(",");
		//avoid allways setting unassigned as preselected key
	    if(keys[0] === "" || keys === undefined){
	    	keys = null;
	    }
		this.setSelectedKeys(keys);

		var that = this;

		var lData = this._data;
		this._content = [];
		var dimension_found = false;
		if(lData.dimensions !== undefined){
			for(var i=0;i<lData.dimensions.length;i++){
				if(lData.dimensions[i].key === this.getDDimension()){
					var members = lData.dimensions[i].members;
					if(!this.getDSkipResultRow()){
						this._content = lData.dimensions[i].members;
					}
					else{
						for(var j=0;j<members.length;j++){
							if(members[j].type !== 'RESULT'){
								this._content.push(members[j]);
							}
						}
					}
					dimension_found = true;
				}
			}
			if(!dimension_found){
				this.setPlaceholder("Dimension "+this.getDDimension()+" doesn't match on DataSource!");
			}
		}else{
			this.setPlaceholder(this.placeholderTextLocalized);
			//try to extract values from Item list setter
			var list = this.getDItemList();
			if(list !== ""){
				try{
					list = JSON.parse(list);
					for(var i=0;i<list.length;i++){
						//erase '"' to prettify titles since json string usually come with '"'
						var replacer = new RegExp('"','g');
						var label = list[i].label;
						var key = list[i].key;

						list[i].key = key.replace(replacer,'');
						//convert Collection object key "label" to match the data model ("text")
						list[i].text = label.replace(replacer,'');
						this._content.push(list[i]);
					}
				}catch (err){
					if(window.console){
						console.log(err);
					}
				}
			}
		}

		//apply sorting
		if(this.getDSorting() === "By Key"){
			if(this.getDSortingDirection() === "Ascending"){
				this._content.sort(function(a,b){
					if(that.isInteger(a.key)){
						return that.compareIntegers(a.key, b.key);
					}else{
						return that.compareText(a.key, b.key);
					}
				});
			}else{
				this._content.sort(function(a,b){
					if(that.isInteger(a.key)){
						return that.compareIntegers(b.key, a.key);
					}else{
						return that.compareText(b.key, a.key);
					}
				});
			}
		}else{
			if(this.getDSortingDirection() === "Ascending"){
				this._content.sort(function(a,b){
					return that.compareText(a.text, b.text);
				});
			}else{
				this._content.sort(function(a,b){
					return that.compareText(b.text, a.text);
				});
			}
		}
		//put default values to handle selection (everything selected or nothing) more gracefully
		this._content.unshift({"key":"CLEAR","text":this.getDSelectNoText()},{"key":"ALL","text":this.getDSelectAllText()});
		// define model
		this._oModel.setData({
			items: this._content,
			editable: true,
			tooltip: this.getDTooltip()
		});
	},
	replaceAll: function(string, find, replace) {
		  return string.replace(new RegExp(this.escapeRegExp(find), 'g'), replace);
	},
	escapeRegExp: function(string) {
	    return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
	},
	isInteger: function(value){
		var regex = /^\d+|"\d+"$/;
		return regex.test(value);
	},
	compareIntegers: function(value1, value2) {
		if ((value1 == null || value1 == undefined || value1 == '') &&
		(value2 == null || value2 == undefined || value2 == '')) return 0;
		if ((value1 == null || value1 == undefined || value1 == '')) return -1;
		if ((value2 == null || value2 == undefined || value2 == '')) return 1;
		if(parseInt(value1) < parseInt(value2)) return -1;
		if(parseInt(value1) == parseInt(value2)) return 0;
		if(parseInt(value1) > parseInt(value2)) return 1;
	},
	/**
	 * Compare simple text with respect to language
	 * @param value1
	 * @param value2
	 * @returns
	 */
	compareText: function(value1, value2){
		//make sure no uppercase characte mix disturbs the sorting
		value1 = value1.toLowerCase();
		value2 = value2.toLowerCase();
	    return value1.localeCompare(value2);
	},
	getBexStringFromSelection: function(items){
		var keys = [];
		for(var i=0;i<items.length;i++){
			if(items[i] !== "ALL" && items[i] !== "ALL"){
				keys.push(items[i]);
			}
		}
		//get values bex variable ready (has to be seperated by semicolons!)
		var keysBexReady = JSON.stringify(keys)
		keysBexReady = keysBexReady.substring(2,keysBexReady.length-2);
		keysBexReady = this.replaceAll(keysBexReady,",",";")
		keysBexReady = this.replaceAll(keysBexReady,'"',"");
		return keysBexReady;
	}/*,
	onAfterRendering : function() {
		  if (sap.m.MultiComboBox.prototype.onAfterRendering) {
		    sap.m.MultiComboBox.prototype.onAfterRendering.apply(this);
		  }
		  var model = this.getModel();
		  if (model) {
		    var selectedKeys = model.getProperty('/selected');
		    if (selectedKeys) {
		      this.setSelectedKeys(selectedKeys);
		    } else {
		      this.setSelectedKeys([]);
		    }
		  } else {
		    this.setSelectedKeys([]);
		  }
		}*/
});


text:
    <md-toolbar>

            <md-button ng-click="toggleLeft()" hide-gt-sm>
                menu
            </md-button>

                My bucketlist

            Logout

    </md-toolbar>

        <md-sidenav md-component-id="left" layout="column" md-is-locked-open="$mdMedia('gt-sm')" class="md-whiteframe-z2">
             <md-subheader class="md-no-sticky">
               <md-input-container flex="100">
                 <input ng-model="search.who" placeholder="Search bucketlist">
               </md-input-container>
             </md-subheader>
             <md-list>
                <md-list-item ng-click="selectBucketlist(bucket)" class="md-1-line" ng-repeat="bucket in bucketlists | filter:search.who">

{{ bucket.name }}

                </md-list-item>
            </md-list>
        </md-sidenav>
        <md-content layout="column" layout-margin layout-padding flex>
            <md-card layout="column" layout-align="center center">
                <md-card-title layout-margin layout-padding flex class="dashboard">
                    <md-card-title-text>{{ bucket.name }}</md-card-title-text>
                </md-card-title>
                <form layout="row" ng-submit="createBucketItem({bid: bucket.id, bucketlist: bucket.id })">
                    <md-whiteframe class="md-whiteframe container" layout="column">

                           <md-input-container layout="column" flex="80">
                                Enter an item...
                                <input type="text" ng-model="newitem.name"/>
                            </md-input-container>
                            <md-button flex="20" class="button-add-item" layout="column" class="md-raised md-primary" type="submit" flex ng-disabled="!newitem.name">
                                add
                                <md-tooltip>Create your bucket</md-tooltip>
                            </md-button>

                    </md-whiteframe>
                </form>
                <md-whiteframe layout="row" class="md-whiteframe container">
                    <md-input-container layout="column" layout-align="center center">
                        <md-list>
                            <md-list-item class="md-2-line" ng-repeat="item in bucket.items | orderBy:'done'">
                                <md-checkbox ng-model="item.done" ng-change="toggleDone(item, item.id, bucket.id)">
                                </md-checkbox>

{{item.name}}

                                <md-button flex="10" class="md-raised" ng-click="deleteBucketItem($event, { bid: bucket.id, id: item.id})">
                                    delete
                                    <md-tooltip>Delete item</md-tooltip>
                            </md-button>
                            </md-list-item>
                        </md-list>
                    </md-input-container>
                </md-whiteframe>
            </md-card>
        </md-content>


text:
<?php

namespace Kalnoy\LaravelCommon\Validation;

use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Validation\Validator as ValidatorContract;
use Illuminate\Http\Request;

abstract class DataValidator implements ValidatorContract
{
    /**
     * @var \Illuminate\Validation\Validator
     */
    protected $validator;

    /**
     * @param $data
     */
    public function __construct($data)
    {
        $this->validator = $this->validator($this->arrayableData($data));
    }

    /**
     * @param array $data
     *
     * @return \Illuminate\Validation\Validator
     */
    private function validator(array $data)
    {
        $factory = app(\Illuminate\Validation\Factory::class);

        $validator = $factory->make(
            $data,
            app()->call([ $this, 'rules' ]),
            $this->messages(),
            $this->attributes()
        );

        if (method_exists($this, 'customize')) {
            app()->call([ $this, 'customize' ], [ $validator ]);
        }

        return $validator;
    }

    /**
     * @return array
     */
    protected function messages()
    {
        return [ ];
    }

    /**
     * @return array
     */
    protected function attributes()
    {
        return [ ];
    }

    /**
     * @param $data
     *
     * @return array
     */
    private function arrayableData($data)
    {
        if (is_array($data)) return $data;

        if ($data instanceof Arrayable) return $data->toArray();

        if ($data instanceof Request) return $data->all();

        throw new \RuntimeException;
    }

    /**
     * @inheritDoc
     */
    public function fails()
    {
        return $this->validator->fails();
    }

    /**
     * @inheritDoc
     */
    public function failed()
    {
        return $this->validator->failed();
    }

    /**
     * @return bool
     */
    public function passes()
    {
        return $this->validator->passes();
    }

    /**
     * @inheritDoc
     */
    public function sometimes($attribute, $rules, callable $callback)
    {
        $this->validator->sometimes($attribute, $rules, $callback);
    }

    /**
     * @inheritDoc
     */
    public function after($callback)
    {
        $this->validator->after($callback);
    }

    /**
     * @inheritDoc
     */
    public function getMessageBag()
    {
        return $this->validator->getMessageBag();
    }

    /**
     * @return \Illuminate\Support\MessageBag
     */
    public function errors()
    {
        return $this->validator->errors();
    }

}


text:
class CreatePurchaseTypes < ActiveRecord::Migration
  def change
    create_table :purchase_types do |t|
      t.string :name, null:false

      t.timestamps null:false
    end
  end
end


text:
from sqlalchemy import Column, String, Integer
from app import Base

class User(Base):
	__tablename__ = 'users'
	id = Column(Integer, primary_key=True)
	username = Column(String(100), unique=True, nullable=False)
	email = Column(String(100), unique=True, nullable=False)
	password = Column(String(100), nullable=False)

	def __init__(self, username, email, password):
		self.username = username
		self.email = email
		self.password = password

	def __repr__(self):
		return '<User(username:%s, email:%s)>' % (self.username, self.email)


text:
require 'spec_helper'

describe "manifestation_types/new" do
  before(:each) do
    assign(:manifestation_type, stub_model(ManifestationType,
      :name => "MyString",
      :display_name => "MyText",
      :note => "MyText",
      :position => 1
    ).as_new_record)
  end

  it "renders new manifestation_type form" do
    render

    # Run the generator again with the --webrat flag if you want to use webrat matchers
    assert_select "form", :action => manifestation_types_path, :method => "post" do
      assert_select "input#manifestation_type_name", :name => "manifestation_type[name]"
      assert_select "textarea#manifestation_type_display_name", :name => "manifestation_type[display_name]"
      assert_select "textarea#manifestation_type_note", :name => "manifestation_type[note]"
      assert_select "input#manifestation_type_position", :name => "manifestation_type[position]"
    end
  end
end


text:
using System;
using System.Runtime.InteropServices;

namespace CommonHelperLibrary.Dwm
{
    internal class NativeMethods
    {
        [DllImport("dwmapi.dll", PreserveSig = false)]
        internal static extern void DwmGetColorizationColor(out uint colorizationColor, [MarshalAs(UnmanagedType.Bool)]out bool colorizationOpaqueBlend);

        [DllImport("dwmapi.dll", PreserveSig = false)]
        internal static extern void DwmIsCompositionEnabled([MarshalAs(UnmanagedType.Bool)] out bool enabled);

        [DllImport("dwmapi.dll", PreserveSig = false)]
        internal static extern void DwmEnableBlurBehindWindow(IntPtr hwnd, ref DwmBlurbehind blurBehind);

        [DllImport("Gdi32.dll")]
        internal static extern IntPtr CreateRectRgn([In] int nLeftRect, [In] int nTopRect, [In] int nRightRect, [In] int nBottomRect);
        [DllImport("Gdi32.dll")]
        internal static extern bool DeleteObject([In] IntPtr hObject);
    }
}


text:
import os
import webbrowser

from invoke import task

docs_dir = 'docs'
build_dir = os.path.join(docs_dir, '_build')

@task
def test(ctx):
    ctx.run("python run_tests.py", pty=True)

@task
def clean(ctx):
    ctx.run("rm -rf build")
    ctx.run("rm -rf dist")
    ctx.run("rm -rf textblob.egg-info")
    clean_docs(ctx)
    print("Cleaned up.")

@task
def clean_docs(ctx):
    ctx.run("rm -rf %s" % build_dir)

@task
def browse_docs(ctx):
    path = os.path.join(build_dir, 'index.html')
    webbrowser.open_new_tab(path)

@task
def docs(ctx, clean=False, browse=False):
    if clean:
        clean_docs(ctx)
    ctx.run("sphinx-build %s %s" % (docs_dir, build_dir), pty=True)
    if browse:
        browse_docs(ctx)

@task
def readme(ctx, browse=False):
    ctx.run("rst2html.py README.rst > README.html", pty=True)
    if browse:
        webbrowser.open_new_tab('README.html')

@task
def doctest(ctx):
    os.chdir(docs_dir)
    ctx.run("make doctest")

@task
def publish(ctx, test=False):
    """Publish to the cheeseshop."""
    clean(ctx)
    if test:
        ctx.run('python setup.py register -r test sdist bdist_wheel', echo=True)
        ctx.run('twine upload dist/* -r test', echo=True)
    else:
        ctx.run('python setup.py register sdist bdist_wheel', echo=True)
        ctx.run('twine upload dist/*', echo=True)


text:
package com.arialyy.aria.core.command;

import com.arialyy.aria.core.download.AbsGroupTaskWrapper;
import com.arialyy.aria.core.download.DGTaskWrapper;
import com.arialyy.aria.core.queue.DGroupTaskQueue;
import com.arialyy.aria.core.task.AbsGroupTask;
import com.arialyy.aria.core.task.AbsTask;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil;

/**
 * Created by AriaL on 2017/6/29.
 * 任务组命令
 */
public abstract class AbsGroupCmd<T extends AbsGroupTaskWrapper> extends AbsCmd<T> {
  /**
   * 需要控制的子任务url
   */
  String childUrl;

  AbsGroupTask tempTask;

  AbsGroupCmd(T entity) {
    mTaskWrapper = entity;
    TAG = CommonUtil.getClassName(this);
    if (entity instanceof DGTaskWrapper) {
      mQueue = DGroupTaskQueue.getInstance();
      isDownloadCmd = true;
    }
  }

  /**
   * 创建任务
   *
   * @return 创建的任务
   */
  AbsTask createTask() {
    tempTask = (AbsGroupTask) mQueue.createTask(mTaskWrapper);
    return tempTask;
  }

  boolean checkTask() {
    tempTask = (AbsGroupTask) mQueue.getTask(mTaskWrapper.getEntity().getKey());
    if (tempTask == null) {
      createTask();
      if (tempTask.isComplete()) {
        ALog.i(TAG, "任务已完成");
        return false;
      }
    }
    return true;
  }
}


text:
define(['./service-definition-visitor', './ballerina-ast-root-visitor',
    './resource-definition-visitor', './function-definition-visitor', './try-catch-statement-visitor'],
    function (ServiceDefinitionVisitor, BallerinaASTRootVisitor, ResourceDefinitionVisitor,
              FunctionDefinitionVisitor, TryCatchStatementVisitor) {
        return  {
            ServiceDefinitionVisitor: ServiceDefinitionVisitor,
            ResourceDefinitionVisitor: ResourceDefinitionVisitor,
            BallerinaASTRootVisitor: BallerinaASTRootVisitor,
            FunctionDefinitionVisitor: FunctionDefinitionVisitor,
            TryCatchStatementVisitor: TryCatchStatementVisitor
        }
    });


text:
/*****************************************************************************
stack.h:
   Simple stack manipulation
*****************************************************************************/

#ifndef _STACK_H
#define _STACK_H

#include <time.h>
#include "lp.h"
#include "cJSON.h"

#define LP_MAX_NAME_LEN (256)
#define LP_MAX_SOURCE_LEN (256)
#define LP_MAX_WHAT_LEN (16)

typedef enum _eDebugInfoType{
	FUNCTION_HOOK = 1,
	FRAME = 2,
}eDebugInfoType;

typedef struct _lprof_DebugInfo {
  eDebugInfoType type;
  int event;
  char name[LP_MAX_NAME_LEN];	/* (n) */

  char what[LP_MAX_WHAT_LEN];	/* (S) `Lua', `C', `main', `tail' */
  char source[LP_MAX_SOURCE_LEN];	/* (S) */

  char ccallname[100];

  char* p_name;
  char* p_what;
  char* p_source;
  char* p_namewhat;
  int currentline;	/* (l) */
  int linedefined;	/* (S) */
  int lastlinedefined;	/* (S) */

  LARGE_INTEGER currenttime;

  // Ó¦¸Ã·ÅÁ½¸ö½á¹¹ÌåÖУ¬¼òµ¥Æð¼û£¬ÏÖÔÚ¹²Ó㬻áÀË·ÑÄÚ´æ
  int frameid;
  int unitytime;

  double framecs;
  double hook_cost_cs;
  int    hook_call_cnt;
}lprof_DebugInfo;

#define MAX_FUNCTION_NAME_LENGTH 200
#define MAX_OUTPUT_MESSAGE_LENGTH 100

//extern FILE *outf;

typedef enum {none,lua,nolua}calltype;

typedef struct lprofS_sSTACK_RECORD lprofS_STACK_RECORD;

struct lprofS_sSTACK_RECORD {
	clock_t time_marker_function_local_time;
	clock_t time_marker_function_total_time;
	char *file_defined;
	char *function_name;
	char *source_code;
	char *what;
	long line_defined;
	long current_line;
	double local_time;
	double interval_time;
	time_t current_time;
	int stack_level;
	LARGE_INTEGER time_maker_local_time_begin;
	LARGE_INTEGER time_maker_local_time_end;
	lprofS_STACK_RECORD *next;
};

typedef lprofS_STACK_RECORD *lprofS_STACK;

typedef struct lprofP_sSTATE lprofP_STATE;

typedef struct lprofS_TREE_RECORD lprofT_NODE;

struct lprofS_TREE_RECORD
{
	int stack_level;
	lprofS_STACK pNode;
	lprofT_NODE* pParent;
	lprofT_NODE* pChild;
	int nChildCount;
	//int nMaxChildCount;
};

struct lprofP_sSTATE {
   int stack_level;
   lprofS_STACK stack_top;
};

void lprofS_push(lprofS_STACK *p, lprofS_STACK_RECORD r, lprof_DebugInfo* dbg_info);
lprofS_STACK_RECORD lprofS_pop(lprofS_STACK *p, lprof_DebugInfo* dbg_info);

void lprofT_init();
void lprofT_start();
void lprofT_add(lprofS_STACK pChild, lprof_DebugInfo* dbg_info);
void lprofT_pop();
//void lprofT_output(lprofT_NODE* p);
//void lprofT_print();
void lprofT_frame(int id,int unitytime, double frame_cs,double hook_cost_cs, int hook_cnt);
lprofT_NODE* lprofT_createNode();
lprofS_STACK lprofT_assigningStack(lprofS_STACK pDest,lprofS_STACK pSource);
lprofT_NODE* lprofT_assigningNode(lprofT_NODE* pDest,lprofT_NODE* pSource);
lprofT_NODE* lprofT_addchild(lprofT_NODE* pParent, lprofT_NODE* pChild);
void lprofT_free(lprofT_NODE* p);
void freeNode(lprofT_NODE* p);
void output(const char *format, ...);
void lprofT_tojson();
//void lprofT_tojson2(lprofT_NODE* p);
//void lprofT_tojson(lprofT_NODE* p);
//void lprofT_tojson_thread();
void lprofT_close();
cJSON* treeTojson(lprofT_NODE* p, calltype precalltype, double* pdLuaConsuming, double* pdFunConsuming, double* topFunCs);
//void freeTree(lprofT_NODE* p);
#endif


text:
require 'rapid_api/model_adapters/abstract'
require 'rapid_api/model_adapters/query_result'
require 'rapid_api/model_adapters/active_record_adapter'

module RapidApi
  module ModelAdapters

  end
end


text:
nogit
=====

Disable Git SCC plug-in in Visual Studio (2013 and above)


text:
/**
@Name: Element.prototype.setCursorPosition
@Description: Sets the cursor position within a textarea
@Example:
myElement.setCursorPosition

*/
Element.prototype.setCursorPosition = function(start,end){
	end = end || start;
	if(this.setSelectionRange){
		this.setSelectionRange(start, end);
	} else if(this.createTextRange){
		var range = this.createTextRange();
		range.collapse(true);
		range.moveEnd('character', start);
		range.moveStart('character', end);
		range.select();
	}
};


text:
module.exports = {
    'BlockBreakEvent': 'org.bukkit.event.block.BlockBreakEvent',
    'BlockBurnEvent': 'org.bukkit.event.block.BlockBurnEvent',
    'BlockCanBuildEvent': 'org.bukkit.event.block.BlockCanBuildEvent',
    'BlockDamageEvent': 'org.bukkit.event.block.BlockDamageEvent',
    'BlockDispenseEvent': 'org.bukkit.event.block.BlockDispenseEvent',
    'BlockEvent': 'org.bukkit.event.block.BlockEvent',
    'BlockExpEvent': 'org.bukkit.event.block.BlockExpEvent',
    'BlockExplodeEvent': 'org.bukkit.event.block.BlockExplodeEvent',
    'BlockFadeEvent': 'org.bukkit.event.block.BlockFadeEvent',
    'BlockFormEvent': 'org.bukkit.event.block.BlockFormEvent',
    'BlockFromToEvent': 'org.bukkit.event.block.BlockFromToEvent',
    'BlockGrowEvent': 'org.bukkit.event.block.BlockGrowEvent',
    'BlockIgniteEvent': 'org.bukkit.event.block.BlockIgniteEvent',
    'BlockMultiPlaceEvent': 'org.bukkit.event.block.BlockMultiPlaceEvent',
    'BlockPhysicsEvent': 'org.bukkit.event.block.BlockPhysicsEvent',
    'BlockPistonEvent': 'org.bukkit.event.block.BlockPistonEvent',
    'BlockPistonExtendEvent': 'org.bukkit.event.block.BlockPistonExtendEvent',
    'BlockPistonRetractEvent': 'org.bukkit.event.block.BlockPistonRetractEvent',
    'BlockPlaceEvent': 'org.bukkit.event.block.BlockPlaceEvent',
    'BlockRedstoneEvent': 'org.bukkit.event.block.BlockRedstoneEvent',
    'BlockSpreadEvent': 'org.bukkit.event.block.BlockSpreadEvent',
    'CauldronLevelChangeEvent': 'org.bukkit.event.block.CauldronLevelChangeEvent',
    'EntityBlockFormEvent': 'org.bukkit.event.block.EntityBlockFormEvent',
    'LeavesDecayEvent': 'org.bukkit.event.block.LeavesDecayEvent',
    'NotePlayEvent': 'org.bukkit.event.block.NotePlayEvent',
    'SignChangeEvent': 'org.bukkit.event.block.SignChangeEvent',
    'EnchantItemEvent': 'org.bukkit.event.enchantment.EnchantItemEvent',
    'PrepareItemEnchantEvent': 'org.bukkit.event.enchantment.PrepareItemEnchantEvent',
    'AreaEffectCloudApplyEvent': 'org.bukkit.event.entity.AreaEffectCloudApplyEvent',
    'CreatureSpawnEvent': 'org.bukkit.event.entity.CreatureSpawnEvent',
    'CreeperPowerEvent': 'org.bukkit.event.entity.CreeperPowerEvent',
    'EnderDragonChangePhaseEvent': 'org.bukkit.event.entity.EnderDragonChangePhaseEvent',
    'EntityBreakDoorEvent': 'org.bukkit.event.entity.EntityBreakDoorEvent',
    'EntityChangeBlockEvent': 'org.bukkit.event.entity.EntityChangeBlockEvent',
    'EntityCombustByBlockEvent': 'org.bukkit.event.entity.EntityCombustByBlockEvent',
    'EntityCombustByEntityEvent': 'org.bukkit.event.entity.EntityCombustByEntityEvent',
    'EntityCombustEvent': 'org.bukkit.event.entity.EntityCombustEvent',
    'EntityCreatePortalEvent': 'org.bukkit.event.entity.EntityCreatePortalEvent',
    'EntityDamageByBlockEvent': 'org.bukkit.event.entity.EntityDamageByBlockEvent',
    'EntityDamageByEntityEvent': 'org.bukkit.event.entity.EntityDamageByEntityEvent',
    'EntityDamageEvent': 'org.bukkit.event.entity.EntityDamageEvent',
    'EntityDeathEvent': 'org.bukkit.event.entity.EntityDeathEvent',
    'EntityEvent': 'org.bukkit.event.entity.EntityEvent',
    'EntityExplodeEvent': 'org.bukkit.event.entity.EntityExplodeEvent',
    'EntityInteractEvent': 'org.bukkit.event.entity.EntityInteractEvent',
    'EntityPortalEnterEvent': 'org.bukkit.event.entity.EntityPortalEnterEvent',
    'EntityPortalEvent': 'org.bukkit.event.entity.EntityPortalEvent',
    'EntityPortalExitEvent': 'org.bukkit.event.entity.EntityPortalExitEvent',
    'EntityRegainHealthEvent': 'org.bukkit.event.entity.EntityRegainHealthEvent',
    'EntityShootBowEvent': 'org.bukkit.event.entity.EntityShootBowEvent',
    'EntitySpawnEvent': 'org.bukkit.event.entity.EntitySpawnEvent',
    'EntityTameEvent': 'org.bukkit.event.entity.EntityTameEvent',
    'EntityTargetEvent': 'org.bukkit.event.entity.EntityTargetEvent',
    'EntityTargetLivingEntityEvent': 'org.bukkit.event.entity.EntityTargetLivingEntityEvent',
    'EntityTeleportEvent': 'org.bukkit.event.entity.EntityTeleportEvent',
    'EntityToggleGlideEvent': 'org.bukkit.event.entity.EntityToggleGlideEvent',
    'EntityUnleashEvent': 'org.bukkit.event.entity.EntityUnleashEvent',
    'ExpBottleEvent': 'org.bukkit.event.entity.ExpBottleEvent',
    'ExplosionPrimeEvent': 'org.bukkit.event.entity.ExplosionPrimeEvent',
    'FireworkExplodeEvent': 'org.bukkit.event.entity.FireworkExplodeEvent',
    'FoodLevelChangeEvent': 'org.bukkit.event.entity.FoodLevelChangeEvent',
    'HorseJumpEvent': 'org.bukkit.event.entity.HorseJumpEvent',
    'ItemDespawnEvent': 'org.bukkit.event.entity.ItemDespawnEvent',
    'ItemMergeEvent': 'org.bukkit.event.entity.ItemMergeEvent',
    'ItemSpawnEvent': 'org.bukkit.event.entity.ItemSpawnEvent',
    'LingeringPotionSplashEvent': 'org.bukkit.event.entity.LingeringPotionSplashEvent',
    'PigZapEvent': 'org.bukkit.event.entity.PigZapEvent',
    'PlayerDeathEvent': 'org.bukkit.event.entity.PlayerDeathEvent',
    'PlayerLeashEntityEvent': 'org.bukkit.event.entity.PlayerLeashEntityEvent',
    'PotionSplashEvent': 'org.bukkit.event.entity.PotionSplashEvent',
    'ProjectileHitEvent': 'org.bukkit.event.entity.ProjectileHitEvent',
    'ProjectileLaunchEvent': 'org.bukkit.event.entity.ProjectileLaunchEvent',
    'SheepDyeWoolEvent': 'org.bukkit.event.entity.SheepDyeWoolEvent',
    'SheepRegrowWoolEvent': 'org.bukkit.event.entity.SheepRegrowWoolEvent',
    'SlimeSplitEvent': 'org.bukkit.event.entity.SlimeSplitEvent',
    'SpawnerSpawnEvent': 'org.bukkit.event.entity.SpawnerSpawnEvent',
    'VillagerAcquireTradeEvent': 'org.bukkit.event.entity.VillagerAcquireTradeEvent',
    'VillagerReplenishTradeEvent': 'org.bukkit.event.entity.VillagerReplenishTradeEvent',
    'HangingBreakByEntityEvent': 'org.bukkit.event.hanging.HangingBreakByEntityEvent',
    'HangingBreakEvent': 'org.bukkit.event.hanging.HangingBreakEvent',
    'HangingEvent': 'org.bukkit.event.hanging.HangingEvent',
    'HangingPlaceEvent': 'org.bukkit.event.hanging.HangingPlaceEvent',
    'BrewEvent': 'org.bukkit.event.inventory.BrewEvent',
    'CraftItemEvent': 'org.bukkit.event.inventory.CraftItemEvent',
    'FurnaceBurnEvent': 'org.bukkit.event.inventory.FurnaceBurnEvent',
    'FurnaceExtractEvent': 'org.bukkit.event.inventory.FurnaceExtractEvent',
    'FurnaceSmeltEvent': 'org.bukkit.event.inventory.FurnaceSmeltEvent',
    'InventoryClickEvent': 'org.bukkit.event.inventory.InventoryClickEvent',
    'InventoryCloseEvent': 'org.bukkit.event.inventory.InventoryCloseEvent',
    'InventoryCreativeEvent': 'org.bukkit.event.inventory.InventoryCreativeEvent',
    'InventoryDragEvent': 'org.bukkit.event.inventory.InventoryDragEvent',
    'InventoryEvent': 'org.bukkit.event.inventory.InventoryEvent',
    'InventoryInteractEvent': 'org.bukkit.event.inventory.InventoryInteractEvent',
    'InventoryMoveItemEvent': 'org.bukkit.event.inventory.InventoryMoveItemEvent',
    'InventoryOpenEvent': 'org.bukkit.event.inventory.InventoryOpenEvent',
    'InventoryPickupItemEvent': 'org.bukkit.event.inventory.InventoryPickupItemEvent',
    'PrepareAnvilEvent': 'org.bukkit.event.inventory.PrepareAnvilEvent',
    'PrepareItemCraftEvent': 'org.bukkit.event.inventory.PrepareItemCraftEvent',
    'AsyncPlayerChatEvent': 'org.bukkit.event.player.AsyncPlayerChatEvent',
    'AsyncPlayerPreLoginEvent': 'org.bukkit.event.player.AsyncPlayerPreLoginEvent',
    'PlayerAchievementAwardedEvent': 'org.bukkit.event.player.PlayerAchievementAwardedEvent',
    'PlayerAnimationEvent': 'org.bukkit.event.player.PlayerAnimationEvent',
    'PlayerArmorStandManipulateEvent': 'org.bukkit.event.player.PlayerArmorStandManipulateEvent',
    'PlayerBedEnterEvent': 'org.bukkit.event.player.PlayerBedEnterEvent',
    'PlayerBedLeaveEvent': 'org.bukkit.event.player.PlayerBedLeaveEvent',
    'PlayerBucketEmptyEvent': 'org.bukkit.event.player.PlayerBucketEmptyEvent',
    'PlayerBucketEvent': 'org.bukkit.event.player.PlayerBucketEvent',
    'PlayerBucketFillEvent': 'org.bukkit.event.player.PlayerBucketFillEvent',
    'PlayerChangedWorldEvent': 'org.bukkit.event.player.PlayerChangedWorldEvent',
    'PlayerChannelEvent': 'org.bukkit.event.player.PlayerChannelEvent',
    'PlayerChatEvent': 'org.bukkit.event.player.PlayerChatEvent',
    'PlayerChatTabCompleteEvent': 'org.bukkit.event.player.PlayerChatTabCompleteEvent',
    'PlayerCommandPreprocessEvent': 'org.bukkit.event.player.PlayerCommandPreprocessEvent',
    'PlayerDropItemEvent': 'org.bukkit.event.player.PlayerDropItemEvent',
    'PlayerEditBookEvent': 'org.bukkit.event.player.PlayerEditBookEvent',
    'PlayerEggThrowEvent': 'org.bukkit.event.player.PlayerEggThrowEvent',
    'PlayerEvent': 'org.bukkit.event.player.PlayerEvent',
    'PlayerExpChangeEvent': 'org.bukkit.event.player.PlayerExpChangeEvent',
    'PlayerFishEvent': 'org.bukkit.event.player.PlayerFishEvent',
    'PlayerGameModeChangeEvent': 'org.bukkit.event.player.PlayerGameModeChangeEvent',
    'PlayerInteractAtEntityEvent': 'org.bukkit.event.player.PlayerInteractAtEntityEvent',
    'PlayerInteractEntityEvent': 'org.bukkit.event.player.PlayerInteractEntityEvent',
    'PlayerInteractEvent': 'org.bukkit.event.player.PlayerInteractEvent',
    'PlayerInventoryEvent': 'org.bukkit.event.player.PlayerInventoryEvent',
    'PlayerItemBreakEvent': 'org.bukkit.event.player.PlayerItemBreakEvent',
    'PlayerItemConsumeEvent': 'org.bukkit.event.player.PlayerItemConsumeEvent',
    'PlayerItemDamageEvent': 'org.bukkit.event.player.PlayerItemDamageEvent',
    'PlayerItemHeldEvent': 'org.bukkit.event.player.PlayerItemHeldEvent',
    'PlayerJoinEvent': 'org.bukkit.event.player.PlayerJoinEvent',
    'PlayerKickEvent': 'org.bukkit.event.player.PlayerKickEvent',
    'PlayerLevelChangeEvent': 'org.bukkit.event.player.PlayerLevelChangeEvent',
    'PlayerLoginEvent': 'org.bukkit.event.player.PlayerLoginEvent',
    'PlayerMoveEvent': 'org.bukkit.event.player.PlayerMoveEvent',
    'PlayerPickupArrowEvent': 'org.bukkit.event.player.PlayerPickupArrowEvent',
    'PlayerPickupItemEvent': 'org.bukkit.event.player.PlayerPickupItemEvent',
    'PlayerPortalEvent': 'org.bukkit.event.player.PlayerPortalEvent',
    'PlayerPreLoginEvent': 'org.bukkit.event.player.PlayerPreLoginEvent',
    'PlayerQuitEvent': 'org.bukkit.event.player.PlayerQuitEvent',
    'PlayerRegisterChannelEvent': 'org.bukkit.event.player.PlayerRegisterChannelEvent',
    'PlayerResourcePackStatusEvent': 'org.bukkit.event.player.PlayerResourcePackStatusEvent',
    'PlayerRespawnEvent': 'org.bukkit.event.player.PlayerRespawnEvent',
    'PlayerShearEntityEvent': 'org.bukkit.event.player.PlayerShearEntityEvent',
    'PlayerStatisticIncrementEvent': 'org.bukkit.event.player.PlayerStatisticIncrementEvent',
    'PlayerSwapHandItemsEvent': 'org.bukkit.event.player.PlayerSwapHandItemsEvent',
    'PlayerTeleportEvent': 'org.bukkit.event.player.PlayerTeleportEvent',
    'PlayerToggleFlightEvent': 'org.bukkit.event.player.PlayerToggleFlightEvent',
    'PlayerToggleSneakEvent': 'org.bukkit.event.player.PlayerToggleSneakEvent',
    'PlayerToggleSprintEvent': 'org.bukkit.event.player.PlayerToggleSprintEvent',
    'PlayerUnleashEntityEvent': 'org.bukkit.event.player.PlayerUnleashEntityEvent',
    'PlayerUnregisterChannelEvent': 'org.bukkit.event.player.PlayerUnregisterChannelEvent',
    'PlayerVelocityEvent': 'org.bukkit.event.player.PlayerVelocityEvent',
    'MapInitializeEvent': 'org.bukkit.event.server.MapInitializeEvent',
    'PluginDisableEvent': 'org.bukkit.event.server.PluginDisableEvent',
    'PluginEnableEvent': 'org.bukkit.event.server.PluginEnableEvent',
    'PluginEvent': 'org.bukkit.event.server.PluginEvent',
    'RemoteServerCommandEvent': 'org.bukkit.event.server.RemoteServerCommandEvent',
    'ServerCommandEvent': 'org.bukkit.event.server.ServerCommandEvent',
    'ServerEvent': 'org.bukkit.event.server.ServerEvent',
    'ServerListPingEvent': 'org.bukkit.event.server.ServerListPingEvent',
    'ServiceEvent': 'org.bukkit.event.server.ServiceEvent',
    'ServiceRegisterEvent': 'org.bukkit.event.server.ServiceRegisterEvent',
    'ServiceUnregisterEvent': 'org.bukkit.event.server.ServiceUnregisterEvent',
    'TabCompleteEvent': 'org.bukkit.event.server.TabCompleteEvent',
    'VehicleBlockCollisionEvent': 'org.bukkit.event.vehicule.VehicleBlockCollisionEvent',
    'VehicleCollisionEvent': 'org.bukkit.event.vehicule.VehicleCollisionEvent',
    'VehicleCreateEvent': 'org.bukkit.event.vehicule.VehicleCreateEvent',
    'VehicleDamageEvent': 'org.bukkit.event.vehicule.VehicleDamageEvent',
    'VehicleDestroyEvent': 'org.bukkit.event.vehicule.VehicleDestroyEvent',
    'VehicleEnterEvent': 'org.bukkit.event.vehicule.VehicleEnterEvent',
    'VehicleEntityCollisionEvent': 'org.bukkit.event.vehicule.VehicleEntityCollisionEvent',
    'VehicleEvent': 'org.bukkit.event.vehicule.VehicleEvent',
    'VehicleExitEvent': 'org.bukkit.event.vehicule.VehicleExitEvent',
    'VehicleMoveEvent': 'org.bukkit.event.vehicule.VehicleMoveEvent',
    'VehicleUpdateEvent': 'org.bukkit.event.vehicule.VehicleUpdateEvent',
    'LightningStrikeEvent': 'org.bukkit.event.weather.LightningStrikeEvent',
    'ThunderChangeEvent': 'org.bukkit.event.weather.ThunderChangeEvent',
    'WeatherChangeEvent': 'org.bukkit.event.weather.WeatherChangeEvent',
    'WeatherEvent': 'org.bukkit.event.weather.WeatherEvent',
    'ChunkEvent': 'org.bukkit.event.world.ChunkEvent',
    'ChunkLoadEvent': 'org.bukkit.event.world.ChunkLoadEvent',
    'ChunkPopulateEvent': 'org.bukkit.event.world.ChunkPopulateEvent',
    'ChunkUnloadEvent': 'org.bukkit.event.world.ChunkUnloadEvent',
    'PortalCreateEvent': 'org.bukkit.event.world.PortalCreateEvent',
    'SpawnChangeEvent': 'org.bukkit.event.world.SpawnChangeEvent',
    'StructureGrowEvent': 'org.bukkit.event.world.StructureGrowEvent',
    'WorldEvent': 'org.bukkit.event.world.WorldEvent',
    'WorldInitEvent': 'org.bukkit.event.world.WorldInitEvent',
    'WorldLoadEvent': 'org.bukkit.event.world.WorldLoadEvent',
    'WorldSaveEvent': 'org.bukkit.event.world.WorldSaveEvent',
    'WorldUnloadEven': 'org.bukkit.event.world.WorldUnloadEvent'
};


text: export * from './components/navbar.component'


text:
<ivysettings>
    <settings defaultResolver="main" />
    <resolvers>
        <chain name="main">
            <ibiblio name="maven-central" m2compatible="true" />
            <ibiblio name="myget" m2compatible="true" root="https://www.myget.org/F/aquiva-salesforce/maven" />
        </chain>
    </resolvers>
</ivysettings>