vector.hh (fstransform-0.9.3-src) | : | vector.hh (fstransform-0.9.4) | ||
---|---|---|---|---|
skipping to change at line 31 | skipping to change at line 31 | |||
* | * | |||
* Created on: Feb 27, 2011 | * Created on: Feb 27, 2011 | |||
* Author: max | * Author: max | |||
*/ | */ | |||
#ifndef FSREMAP_VECTOR_HH | #ifndef FSREMAP_VECTOR_HH | |||
#define FSREMAP_VECTOR_HH | #define FSREMAP_VECTOR_HH | |||
#include "check.hh" | #include "check.hh" | |||
#include <vector> // for std::vector<T> */ | #include <vector> // for std::vector<T> */ | |||
#include "fwd.hh" // for fr_map<T> | #include "fwd.hh" // for fr_map<T> | |||
#include "extent.hh" // for fr_extent<T> | #include "log.hh" // for ft_log_level, FC_SHOW_DEFAULT_LEVEL. also used by | |||
vector.t.hh for ff_log() | ||||
#include "extent.hh" // for fr_extent<T> | ||||
FT_NAMESPACE_BEGIN | FT_NAMESPACE_BEGIN | |||
template<typename T> | template<typename T> | |||
class fr_vector : public std::vector<fr_extent<T> > | class fr_vector : public std::vector<fr_extent<T> > | |||
{ | { | |||
private: | private: | |||
typedef std::vector<fr_extent<T> > super_type; | typedef std::vector<fr_extent<T> > super_type; | |||
/** actual implementation of compose() below */ | ||||
int compose0(const fr_vector<T> & a2b, const fr_vector<T> & a2c, T & ret_blo | ||||
ck_size_bitmask, fr_vector<T> * unmapped = 0); | ||||
public: | public: | |||
typedef fr_extent_key<T> key_type; | typedef fr_extent_key<T> key_type; | |||
typedef fr_extent_payload<T> mapped_type; | typedef fr_extent_payload<T> mapped_type; | |||
typedef typename super_type::value_type value_type; | typedef typename super_type::value_type value_type; | |||
typedef typename super_type::iterator iterator; | typedef typename super_type::iterator iterator; | |||
typedef typename super_type::const_iterator const_iterator; | typedef typename super_type::const_iterator const_iterator; | |||
/** | /** | |||
* append a single extent to this vector. | * append a single extent to this vector. | |||
skipping to change at line 105 | skipping to change at line 109 | |||
* reorder this vector in-place, sorting by logical | * reorder this vector in-place, sorting by logical | |||
*/ | */ | |||
void sort_by_logical(); | void sort_by_logical(); | |||
void sort_by_logical(iterator from, iterator to); | void sort_by_logical(iterator from, iterator to); | |||
/** | /** | |||
* reorder this vector in-place, sorting by reverse length (largest extents will be first) | * reorder this vector in-place, sorting by reverse length (largest extents will be first) | |||
*/ | */ | |||
void sort_by_reverse_length(); | void sort_by_reverse_length(); | |||
void sort_by_reverse_length(iterator from, iterator to); | void sort_by_reverse_length(iterator from, iterator to); | |||
/** | ||||
* swap ->physical with ->logical in each extent of this vector. | ||||
* Note: does NOT sort after swapping! | ||||
*/ | ||||
void transpose(); | ||||
/** | ||||
* used by ft_io_prealloc. | ||||
* | ||||
* truncate at specified logical value | ||||
*/ | ||||
void truncate_at_logical(T logical_end); | ||||
/** | ||||
* used by ft_io_prealloc. | ||||
* | ||||
* given a vector mapping a->b (v1) and a vector mapping a->c (v2), | ||||
* compute the vector mapping b->c (v2) and append it to this vector. | ||||
* | ||||
* user_data will be copied from v1. | ||||
* all extents in b not mapped to c will be added to 'unmapped' (if not NULL | ||||
) | ||||
* | ||||
* a->b and a->c must be sorted by ->physical | ||||
* returns error if a->b domain (range in a) is smaller than a->c domain (ra | ||||
nge in a) | ||||
* and in particular if a->b has holes where a->c does not. | ||||
*/ | ||||
FT_INLINE int compose(const fr_vector<T> & a2b, const fr_vector<T> & a2c, T | ||||
& ret_block_size_bitmask, fr_vector<T> & unmapped) { | ||||
return compose0(a2b, a2c, ret_block_size_bitmask, & unmapped); | ||||
} | ||||
/** same as compose() above, but does not compute 'block_size_bitmask' and ' | ||||
unmapped' */ | ||||
FT_INLINE int compose(const fr_vector<T> & a2b, const fr_vector<T> & a2c) { | ||||
T block_size_bitmask = 0; | ||||
return compose0(a2b, a2c, block_size_bitmask); | ||||
} | ||||
/** print vector contents to log */ | ||||
void show(const char * label1, const char * label2, ft_uoff effective_block_ | ||||
size, ft_log_level level = FC_SHOW_DEFAULT_LEVEL) const; | ||||
}; | }; | |||
FT_NAMESPACE_END | FT_NAMESPACE_END | |||
#ifdef FT_HAVE_EXTERN_TEMPLATE | #ifdef FT_HAVE_EXTERN_TEMPLATE | |||
# define FT_TEMPLATE_vector_hh(ft_prefix, T) ft_prefix class FT_NS fr_vector< T >; | # define FT_TEMPLATE_vector_hh(ft_prefix, T) ft_prefix class FT_NS fr_vector< T >; | |||
FT_TEMPLATE_DECLARE(FT_TEMPLATE_vector_hh) | FT_TEMPLATE_DECLARE(FT_TEMPLATE_vector_hh) | |||
#else | #else | |||
# include "vector.t.hh" | # include "vector.t.hh" | |||
#endif /* FT_HAVE_EXTERN_TEMPLATE */ | #endif /* FT_HAVE_EXTERN_TEMPLATE */ | |||
End of changes. 4 change blocks. | ||||
3 lines changed or deleted | 53 lines changed or added |