1 #ifndef CORELIB___NCBI_UTILITY__HPP
2 #define CORELIB___NCBI_UTILITY__HPP
78 const typename Pair::second_type& y)
const {
94 template<
class Key,
class Element>
105 template<
class Key,
class Element>
115 template<
class Key,
class Element>
127 if ( ptr != m.
end() )
135 const Key&
key,
const string&
data)
148 for (
typename Cnt::iterator
i =
cnt.begin();
i !=
cnt.end(); ++
i ) {
156 template<
class Key,
class Element>
168 template<
class Key,
class Element>
180 template<
class Result,
class Source,
class ToKey>
183 AutoMap(unique_ptr<Result>& cache,
const Source&
source,
const ToKey& toKey)
185 Result* ret = cache.get();
187 cache.reset(ret =
new Result);
188 for (
typename Source::const_iterator
i =
source.begin();
198 template<
class Value>
203 return value->GetName();
217 template <
typename T,
typename F>
247 template <
typename C,
typename F>
254 ITERATE (
typename C, it, container) {
257 return tracker.GetBestChoice();
263 #if !defined(HAVE_IS_SORTED)
273 template <
class Iterator>
276 Iterator
prev = iter1;
277 for (++iter1; iter1 != iter2; ++iter1, ++
prev) {
278 if (*iter1 < *
prev) {
286 template <
class Iterator,
class Predicate>
289 Iterator
prev = iter1;
290 for (++iter1; iter1 != iter2; ++iter1, ++
prev) {
291 if (pred(*iter1, *
prev)) {
Tracks the best score (lowest value).
container_type::const_iterator const_iterator
container_type::iterator iterator
const_iterator begin() const
const_iterator end() const
iterator_bool insert(const value_type &val)
container_type::value_type value_type
const_iterator find(const key_type &key) const
const_iterator end() const
const_iterator begin() const
Include a standard set of the NCBI C++ Toolkit most basic headers.
static DLIST_TYPE *DLIST_NAME() prev(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_STD_SCOPE
Place it for adding new funtionality to STD scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define END_STD_SCOPE
End previously defined STD scope.
CBestChoiceTracker(F func)
Constructor.
C::value_type FindBestChoice(const C &container, F score_func)
Find the best choice (lowest score) for values in a container.
BEGIN_STD_SCOPE bool is_sorted(Iterator iter1, Iterator iter2)
is_sorted is provided by some implementations of the STL and may be included in future releases of al...
void SetMapElement(map< Key, Element * > &m, const Key &key, Element *data)
Set map element – if data is null, erase the existing key.
bool operator()(const T &x, const T &y) const
F m_Func
Scoring function.
bool InsertMapElement(map< Key, Element * > &m, const Key &key, Element *data)
Insert map element.
X * NotNull(X *object)
Check for not null value (after C malloc, strdup etc.).
int m_Score
Current best score.
bool operator()(const Pair &x, const typename Pair::second_type &y) const
Element GetMapElement(const map< Key, Element > &m, const Key &key, const Element &def=0)
Get map element (pointer) or NULL if absent.
void SetMapString(map< Key, string > &m, const Key &key, const string &data)
Set string map element – if data is null erase the existing key.
void operator()(const T &x)
Define application operator.
const string & GetKey(const Value *value) const
Result & AutoMap(unique_ptr< Result > &cache, const Source &source, const ToKey &toKey)
Retrieve the result from the result cache - if cache is empty, insert into cache from the supplied so...
bool operator()(const T *x, const T *y) const
const T & GetBestChoice()
Get best choice with lowest score.
string GetMapString(const map< Key, string > &m, const Key &key)
Get string map element or "" if absent.
T m_Value
Current best value.
void DeleteElements(Cnt &cnt)
Delete all elements from a container of pointers (list, vector, set, multiset); clear the container a...
double value_type
The numeric datatype used by the parser.
const struct ncbi::grid::netcache::search::fields::KEY key
const GenericPointer< typename T::ValueType > T2 value
const CharType(& source)[N]
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
#define F(x)
Make a parametrized function appear to have only one variable.
Get name attribute for Value object.
Compare objects pointed to by (smart) pointer.
Check for equality of objects pointed to by pointer.
Check whether a pair's second element matches a given value.