Turi Create  4.0
turi::flex_dict_view Class Reference

#include <model_server/lib/flex_dict_view.hpp>

Public Member Functions

 flex_dict_view ()=delete
 
 flex_dict_view (const flex_dict &value)
 
 flex_dict_view (const flexible_type &value)
 
const flexible_typeoperator[] (const flexible_type &key) const
 
bool has_key (const flexible_type &key) const
 
size_t size () const
 
const std::vector< flexible_type > & keys ()
 
const std::vector< flexible_type > & values ()
 
flex_dict::const_iterator begin () const
 
flex_dict::const_iterator end () const
 

Detailed Description

A thin wrapper around flex_dict to facilitate access of the underneath sparse vector.

It can be used the following way, suppose sa_iter is an iterator on top of sarray: flex_dict_view value = (*sa_iter);

Internally, sparse vector points to a flex_dict structure. It will not make copy of the data to avoid memory allocation

Definition at line 25 of file flex_dict_view.hpp.

Constructor & Destructor Documentation

◆ flex_dict_view() [1/3]

turi::flex_dict_view::flex_dict_view ( )
delete

Default constructor.

◆ flex_dict_view() [2/3]

turi::flex_dict_view::flex_dict_view ( const flex_dict value)

Constructs a sparse vector from a flexible type that is DICT type

◆ flex_dict_view() [3/3]

turi::flex_dict_view::flex_dict_view ( const flexible_type value)

Constructs a sparse vector from a flexible type. This only works when the value is of type flex_type_enum::DICT, it will throw otherwise

Member Function Documentation

◆ begin()

flex_dict::const_iterator turi::flex_dict_view::begin ( ) const

Returns an iterator that gives out items from beginning

◆ end()

flex_dict::const_iterator turi::flex_dict_view::end ( ) const

Returns an iterator that points to end position

◆ has_key()

bool turi::flex_dict_view::has_key ( const flexible_type key) const

Returns whether or not a given key exists in the sparse vector

◆ keys()

const std::vector<flexible_type>& turi::flex_dict_view::keys ( )

Returns all keys in a vector

◆ operator[]()

const flexible_type& turi::flex_dict_view::operator[] ( const flexible_type key) const

Given a key retrieve the value, throws if the key doesn't exist

◆ size()

size_t turi::flex_dict_view::size ( ) const

Returns number of elements in the sparse vector

◆ values()

const std::vector<flexible_type>& turi::flex_dict_view::values ( )

Returns all values in a vector


The documentation for this class was generated from the following file: