text:
#ifndef OSMIUM_IO_DETAIL_INPUT_FORMAT_HPP
#define OSMIUM_IO_DETAIL_INPUT_FORMAT_HPP

#include <osmium/io/detail/queue_util.hpp>
#include <osmium/io/error.hpp>
#include <osmium/io/file.hpp>
#include <osmium/io/file_format.hpp>
#include <osmium/io/header.hpp>
#include <osmium/memory/buffer.hpp>
#include <osmium/osm/entity_bits.hpp>
#include <osmium/thread/pool.hpp>

#include <array>
#include <exception>
#include <functional>
#include <future>
#include <memory>
#include <string>
#include <utility>

namespace osmium {

    namespace io {

        namespace detail {

            struct parser_arguments {
                osmium::thread::Pool& pool;
                future_string_queue_type& input_queue;
                future_buffer_queue_type& output_queue;
                std::promise<osmium::io::Header>& header_promise;
                osmium::osm_entity_bits::type read_which_entities;
                osmium::io::read_meta read_metadata;
            };

            class Parser {

                osmium::thread::Pool& m_pool;
                future_buffer_queue_type& m_output_queue;
                std::promise<osmium::io::Header>& m_header_promise;
                queue_wrapper<std::string> m_input_queue;
                osmium::osm_entity_bits::type m_read_which_entities;
                osmium::io::read_meta m_read_metadata;
                bool m_header_is_done;

            protected:

                osmium::thread::Pool& get_pool() {
                    return m_pool;
                }

                osmium::osm_entity_bits::type read_types() const noexcept {
                    return m_read_which_entities;
                }

                osmium::io::read_meta read_metadata() const noexcept {
                    return m_read_metadata;
                }

                bool header_is_done() const noexcept {
                    return m_header_is_done;
                }

                void set_header_value(const osmium::io::Header& header) {
                    if (!m_header_is_done) {
                        m_header_is_done = true;
                        m_header_promise.set_value(header);
                    }
                }

                void set_header_exception(const std::exception_ptr& exception) {
                    if (!m_header_is_done) {
                        m_header_is_done = true;
                        m_header_promise.set_exception(exception);
                    }
                }

                /**
                 * Wrap the buffer into a future and add it to the output queue.
                 */
                void send_to_output_queue(osmium::memory::Buffer&& buffer) {
                    add_to_queue(m_output_queue, std::move(buffer));
                }

                void send_to_output_queue(std::future<osmium::memory::Buffer>&& future) {
                    m_output_queue.push(std::move(future));
                }

            public:

                explicit Parser(parser_arguments& args) :
                    m_pool(args.pool),
                    m_output_queue(args.output_queue),
                    m_header_promise(args.header_promise),
                    m_input_queue(args.input_queue),
                    m_read_which_entities(args.read_which_entities),
                    m_read_metadata(args.read_metadata),
                    m_header_is_done(false) {
                }

                Parser(const Parser&) = delete;
                Parser& operator=(const Parser&) = delete;

                Parser(Parser&&) = delete;
                Parser& operator=(Parser&&) = delete;

                virtual ~Parser() noexcept = default;

                virtual void run() = 0;

                std::string get_input() {
                    return m_input_queue.pop();
                }

                bool input_done() const {
                    return m_input_queue.has_reached_end_of_data();
                }

                void parse() {
                    try {
                        run();
                    } catch (...) {
                        std::exception_ptr exception = std::current_exception();
                        set_header_exception(exception);
                        add_to_queue(m_output_queue, std::move(exception));
                    }

                    add_end_of_data_to_queue(m_output_queue);
                }

            }; // class Parser

            /**
             * This factory class is used to create objects that decode OSM
             * data written in a specified format.
             *
             * Do not use this class directly. Use the osmium::io::Reader
             * class instead.
             */
            class ParserFactory {

            public:

                using create_parser_type = std::function<std::unique_ptr<Parser>(parser_arguments&)>;

            private:

                std::array<create_parser_type, static_cast<std::size_t>(file_format::last) + 1> m_callbacks;

                ParserFactory() noexcept = default;

                create_parser_type& callbacks(const osmium::io::file_format format) noexcept {
                    return m_callbacks[static_cast<std::size_t>(format)];
                }

                const create_parser_type& callbacks(const osmium::io::file_format format) const noexcept {
                    return m_callbacks[static_cast<std::size_t>(format)];
                }

            public:

                static ParserFactory& instance() noexcept {
                    static ParserFactory factory;
                    return factory;
                }

                bool register_parser(const osmium::io::file_format format, create_parser_type&& create_function) {
                    callbacks(format) = std::forward<create_parser_type>(create_function);
                    return true;
                }

                create_parser_type get_creator_function(const osmium::io::File& file) const {
                    const auto func = callbacks(file.format());
                    if (func) {
                        return func;
                    }
                    throw unsupported_file_format_error{
                            std::string{"Can not open file '"} +
                            file.filename() +
                            "' with type '" +
                            as_string(file.format()) +
                            "'. No support for reading this format in this program."};
                }

            }; // class ParserFactory

        } // namespace detail

    } // namespace io

} // namespace osmium

#endif // OSMIUM_IO_DETAIL_INPUT_FORMAT_HPP


text:
package com.graphhopper.storage;

import com.graphhopper.routing.ch.NodeOrderingProvider;
import com.graphhopper.routing.util.AllCHEdgesIterator;
import com.graphhopper.routing.util.EdgeFilter;
import com.graphhopper.util.CHEdgeExplorer;
import com.graphhopper.util.CHEdgeIteratorState;
import com.graphhopper.util.EdgeExplorer;
import com.graphhopper.util.EdgeIteratorState;

/**
 * Extended graph interface which supports Contraction Hierarchies. Ie. storing and retrieving the
 * levels for a node and creating shortcuts, which are additional 'artificial' edges to speedup
 * traversal in certain cases.
 *
 * @author Peter Karich
 */
public interface CHGraph extends Graph {

    /**
     * This methods sets the level of the specified node.
     */
    void setLevel(int nodeId, int level);

    /**
     * @return the level of the specified node. The higher the more important the node is. Virtual nodes have the
     * biggest level associated.
     */
    int getLevel(int nodeId);

    boolean isShortcut(int edgeId);

    /**
     * This method creates a shortcut between a to b which is nearly identical to creating an edge
     * except that it can be excluded or included for certain traversals or algorithms.
     */
    CHEdgeIteratorState shortcut(int a, int b);

    int shortcut(int a, int b, int accessFlags, double weight, double distance, int skippedEdge1, int skippedEdge2);

    int shortcutEdgeBased(int a, int b, int accessFlags, double weight, double distance, int skippedEdge1, int skippedEdge2, int origFirst, int origLast);

    @Override
    CHEdgeIteratorState getEdgeIteratorState(int edgeId, int endNode);

    @Override
    CHEdgeExplorer createEdgeExplorer();

    @Override
    CHEdgeExplorer createEdgeExplorer(EdgeFilter filter);

    EdgeExplorer createOriginalEdgeExplorer();

    EdgeExplorer createOriginalEdgeExplorer(EdgeFilter filter);

    @Override
    AllCHEdgesIterator getAllEdges();

    /**
     * Disconnects the edges (higher to lower node) via the specified edgeState pointing from lower to
     * higher node.
     * <p>
     *
     * @param edgeState the edge from lower to higher
     */
    void disconnect(CHEdgeExplorer edgeExplorer, EdgeIteratorState edgeState);

    /**
     * @return the number of original edges in this graph (without shortcuts)
     */
    int getOriginalEdges();

    NodeOrderingProvider getNodeOrderingProvider();

    /**
     * @return true if contraction can be started (add shortcuts and set levels), false otherwise
     */
    boolean isReadyForContraction();

}

redpajama_set_name: RedPajamaGithub


text:
require 'spec_helper'

describe Impressbox do
  it 'has a version number' do
    expect(Impressbox::VERSION).not_to be nil
  end

  it 'does something useful' do
    expect(false).to eq(true)
  end
end