rangeless::fn
Element Access

Functions

template<typename Container , typename P >
auto rangeless::fn::get_unique (Container &container, P &&pred) -> decltype(*container.begin())
 Access unique element matching the predicate. More...
 
template<typename Container , typename P , typename Construct >
auto rangeless::fn::set_unique (Container &container, P &&pred, Construct &&con) -> decltype(*container.begin())
 Similar to get_unique, but end-insert an element if missing. More...
 
template<typename Container >
auto rangeless::fn::first_or_default (const Container &c) -> typename Container::value_type
 e.g. const CConstRef<CSeq_align> aln = first_or_default( get_alns_annot(...)->Get() ); More...
 
template<typename Container , typename Pred >
auto rangeless::fn::first_or_default (const Container &c, Pred &&pred) -> typename Container::value_type
 
template<typename Container >
auto rangeless::fn::last_or_default (const Container &c) -> typename Container::value_type
 
template<typename Container , typename Pred >
auto rangeless::fn::last_or_default (const Container &c, Pred &&pred) -> typename Container::value_type
 

Detailed Description

Function Documentation

◆ first_or_default() [1/2]

template<typename Container >
auto rangeless::fn::first_or_default ( const Container &  c) -> typename Container::value_type

e.g. const CConstRef<CSeq_align> aln = first_or_default( get_alns_annot(...)->Get() );

Definition at line 4450 of file fn.hpp.

◆ first_or_default() [2/2]

template<typename Container , typename Pred >
auto rangeless::fn::first_or_default ( const Container &  c,
Pred &&  pred 
) -> typename Container::value_type

Definition at line 4456 of file fn.hpp.

◆ get_unique()

template<typename Container , typename P >
auto rangeless::fn::get_unique ( Container &  container,
P &&  pred 
) -> decltype(*container.begin())

Access unique element matching the predicate.

Throw unless found exactly one element matching the predicate. Returns const or non-const reference depending on the constness of the container.

See also
set_unique
const CConstRef<CUser_object>& model_evidence_uo =
fn::get_unique(seq_feat.GetExts(), [](CConstRef<CUser_object> uo)
{
return uo->GetType().GetStr() == "ModelEvidence";
});

Definition at line 4370 of file fn.hpp.

◆ last_or_default() [1/2]

template<typename Container >
auto rangeless::fn::last_or_default ( const Container &  c) -> typename Container::value_type

Definition at line 4463 of file fn.hpp.

◆ last_or_default() [2/2]

template<typename Container , typename Pred >
auto rangeless::fn::last_or_default ( const Container &  c,
Pred &&  pred 
) -> typename Container::value_type

Definition at line 4469 of file fn.hpp.

◆ set_unique()

template<typename Container , typename P , typename Construct >
auto rangeless::fn::set_unique ( Container &  container,
P &&  pred,
Construct &&  con 
) -> decltype(*container.begin())

Similar to get_unique, but end-insert an element if missing.

CRef<CSeqdesc>& gb_desc =
fn::set_unique(seq_entry.SetDescr().Set(), [](CConstRef<CSeqdesc> d)
{
return d->IsGenbank();
},
[] // add if missing (must satisfy pred)
{
auto g = Ref(new CSeqdesc);
g->SetGenbank();
return g;
});

Definition at line 4413 of file fn.hpp.