<commit_before>/******************************************************************************
 *  Dependencies: none
 *
 *  code to represent an edge in a graph.
 *
 ******************************************************************************/
#ifndef __EDGE_H__
#define __EDGE_H__

#include <iostream>
#include <sstream>
#include <string>

#include "object.h"
#include "cstdin.h"

namespace edu {
namespace princeton {
namespace cs {
namespace algs4 {

using std::istream;
using std::cin;
using std::endl;
using std::string;
using std::stringstream;

using edu::princeton::cs::algs4::cstdin;
using com::goffersoft::core::object;

/**
 **  The edge_base class represents a edge and is the base class
 **  Each edge consists of two integers (naming the two vertices).
 **  The data type provides methods for accessing the two endpoints
 **  of the edge.  
 **  2 comparision functions are provided incase this class needs to
 **  be sorted by the first or the second end-point.
 **
 **  Memory <= 8 bytes (4 + 4).
 **  This is an immutable class.
 **/
class edge_base {
    public :
        using vertex_type = uint32_t;
        using edge_type = edge_base;

        edge_base(const vertex_type& first,
                  const vertex_type& second) :
             first(first),
             second(second) {}

        edge_base(istream& is = cin) :
            first(cstdin::read_uint32(is)),
            second(cstdin::read_uint32(is)) {}

        const vertex_type get_first() const {
            return first;
        }

        const vertex_type& get_second() const {
            return second;
        }

        static int32_t cmp_by_first_vertex(
                           const edge_type& lhs,
                           const edge_type& rhs) {
            if(&lhs == &rhs)
                return 0;
            return utils::cmp(lhs.get_first(), lhs.get_second(),
                              rhs.get_first(), rhs.get_second());
        };

        static int32_t cmp_by_second_vertex(
                           const edge_type& lhs,
                           const edge_type& rhs) {
            if(&lhs == &rhs)
                return 0;
            return utils::cmp(lhs.get_second(), lhs.get_first(),
                              rhs.get_second(), rhs.get_first());
        };

        bool is_equal(const edge_type& that) const {
            return ( this->first == that.first &&
                     this->second == that.second);<commit_msg>add more compare methods<commit_after>/******************************************************************************
 *  Dependencies: none
 *
 *  code to represent an edge in a graph.
 *
 ******************************************************************************/
#ifndef __EDGE_H__
#define __EDGE_H__

#include <iostream>
#include <sstream>
#include <string>

#include "object.h"
#include "cstdin.h"

namespace edu {
namespace princeton {
namespace cs {
namespace algs4 {

using std::istream;
using std::cin;
using std::endl;
using std::string;
using std::stringstream;

using edu::princeton::cs::algs4::cstdin;
using com::goffersoft::core::object;

/**
 **  The edge_base class represents a edge and is the base class
 **  Each edge consists of two integers (naming the two vertices).
 **  The data type provides methods for accessing the two endpoints
 **  of the edge.  
 **  2 comparision functions are provided incase this class needs to
 **  be sorted by the first or the second end-point.
 **
 **  Memory <= 8 bytes (4 + 4).
 **  This is an immutable class.
 **/
class edge_base {
    public :
        using vertex_type = uint32_t;
        using edge_type = edge_base;

        edge_base(const vertex_type& first,
                  const vertex_type& second) :
             first(first),
             second(second) {}

        edge_base(istream& is = cin) :
            first(cstdin::read_uint32(is)),
            second(cstdin::read_uint32(is)) {}

        const vertex_type get_first() const {
            return first;
        }

        const vertex_type& get_second() const {
            return second;
        }

        static int32_t cmp_by_first_vertex(
                           const edge_type& lhs,
                           const edge_type& rhs) {
            if(&lhs == &rhs)
                return 0;
            return utils::cmp(lhs.get_first(), lhs.get_second(),
                              rhs.get_first(), rhs.get_second());
        }

        static int32_t cmp_by_first_vertex_descending(
                           const edge_type& lhs,
                           const edge_type& rhs) {
            return -utils::cmp(lhs.get_first(), lhs.get_second(),
                               rhs.get_first(), rhs.get_second());
        }

        static int32_t cmp_by_second_vertex(
                           const edge_type& lhs,
                           const edge_type& rhs) {
            if(&lhs == &rhs)
                return 0;
            return utils::cmp(lhs.get_second(), lhs.get_first(),
                              rhs.get_second(), rhs.get_first());
        }

        static int32_t cmp_by_second_vertex_descending(
                           const edge_type& lhs,
                           const edge_type& rhs) {
            return -utils::cmp(lhs.get_second(), lhs.get_first(),
                              rhs.get_second(), rhs.get_first());
        }

        bool is_equal(const edge_type& that) const {
            return ( this->first == that.first &&
                     this->second == that.second);
{'fraction_non_alphanumeric': 0.15337312353047566, 'fraction_numerical': 0.007234581298607343, 'mean_word_length': 2.0136239782016347, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4208073', 'n_tokens_mistral': 1574, 'n_tokens_neox': 1521, 'n_words': 410}