/*
- * Copyright (c) 2016, Intel Corporation
+ * Copyright (c) 2016-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
#ifndef UTIL_HASH_H
#define UTIL_HASH_H
+#include <iterator>
#include <boost/functional/hash/hash_fwd.hpp>
namespace ue2 {
return v;
}
+/**
+ * \brief Compute the hash of all the elements of any range on which we can
+ * call std::begin() and std::end().
+ */
+template<typename Range>
+size_t hash_range(const Range &r) {
+ return boost::hash_range(std::begin(r), std::end(r));
+}
+
} // namespace ue2
#endif // UTIL_HASH_H
/*
- * Copyright (c) 2015-2016, Intel Corporation
+ * Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
#include "ue2common.h"
#include "util/charreach.h"
+#include "util/hash.h"
#include <iterator>
#include <string>
std::vector<bool> nocase; /* for trolling value */
};
+inline
+size_t hash_value(const ue2_literal::elem &elem) {
+ return hash_all(elem.c, elem.nocase);
+}
+
+inline
+size_t hash_value(const ue2_literal &lit) { return hash_range(lit); }
/// Return a reversed copy of this literal.
ue2_literal reverse_literal(const ue2_literal &in);