Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
geo::part::SortedPartition< Data, Sorter > Class Template Reference

Partition of area sorted across a dimension. More...

#include <Partitions.h>

Inheritance diagram for geo::part::SortedPartition< Data, Sorter >:
geo::part::PartitionContainer< Data > geo::part::PartitionWithData< Data > geo::part::Partition< Data > geo::part::PartitionBase geo::part::AreaOwner

Public Types

using Base_t = PartitionContainer< Data >
 Base class. More...
 
using Partition_t = Partition< Data >
 Base type of the partition. More...
 
using Sorter_t = Sorter
 Type of sorter being used. More...
 
using Data_t = typename Partition_t::Data_t
 
using Area_t = typename Partition_t::Area_t
 
using Subpartitions_t = typename Base_t::Subpartitions_t
 
- Public Types inherited from geo::part::PartitionContainer< Data >
using Base_t = PartitionWithData< Data >
 Base class. More...
 
using Partition_t = Partition< Data >
 Base type of the partition. More...
 
using Data_t = typename Partition_t::Data_t
 
using Area_t = typename Partition_t::Area_t
 
using Subpartitions_t = typename Partition_t::Subpartitions_t
 
- Public Types inherited from geo::part::PartitionWithData< Data >
using Base_t = Partition< Data >
 Base class. More...
 
using Partition_t = Partition< Data >
 Base type of the partition. More...
 
using Data_t = typename Partition_t::Data_t
 Type of contained data. More...
 
using Area_t = typename Partition_t::Area_t
 Type of covered area. More...
 
- Public Types inherited from geo::part::Partition< Data >
using Data_t = Data
 Type of data stored in the partition. More...
 
using Partition_t = Partition< Data >
 This type. More...
 
using Area_t = PartitionBase::Area_t
 Type of area. More...
 
using Subpartitions_t = std::vector< std::unique_ptr< Partition_t const >>
 Type of list of subpartitions. It needs to preserve polymorphism. More...
 
- Public Types inherited from geo::part::PartitionBase
using Area_t = AreaOwner::Area_t
 
using AreaRangeMember_t = AreaOwner::AreaRangeMember_t
 
- Public Types inherited from geo::part::AreaOwner
using Area_t = lar::util::simple_geo::Rectangle< double >
 Type of area covered by the partition. More...
 
using AreaRangeMember_t = Area_t::Range_t(Area_t::*)
 Type of pointer to Area_t data member of type Range_t. More...
 

Public Member Functions

 SortedPartition (Area_t const &area, Subpartitions_t &&subpartitions, Data_t *defData=nullptr, Sorter_t sorter={})
 Constructor: sets the partition. More...
 
- Public Member Functions inherited from geo::part::PartitionContainer< Data >
virtual Data_tatPoint (double w, double d) const override
 Returns stored datum only if point is covered, nullptr otherwise. More...
 
- Public Member Functions inherited from geo::part::PartitionWithData< Data >
 PartitionWithData (Area_t const &area, Data_t *myData)
 Constructor: sets the covered area and the contained datum. More...
 
virtual Data_tdata () const override
 Returns the datum directly stored (nullptr if none). More...
 
- Public Member Functions inherited from geo::part::Partition< Data >
 Partition (Area_t const &area)
 Constructor: sets the covered area and no subpartitions. More...
 
virtual ~Partition ()=default
 Destructor (default, virtual). More...
 
std::string describe (std::string indent, std::string firstIndent) const
 Returns a description of the partition. More...
 
std::string describe (std::string indent="") const
 Returns a description of the partition. More...
 
template<typename Pred >
void walk (Pred &&pred) const
 Applies pred to all partitions. More...
 
std::size_t nParts () const
 Returns the number of subparts in the partition (0 if simple element). More...
 
- Public Member Functions inherited from geo::part::PartitionBase
 PartitionBase (Area_t const &area)
 Constructor: sets the covered area and no subpartitions. More...
 
- Public Member Functions inherited from geo::part::AreaOwner
 AreaOwner (Area_t const &area)
 Constructor: sets the covered area and no subpartitions. More...
 
bool contains (double w, double d) const
 Returns whether the specified point is covered by this object. More...
 
Area_t const & area () const
 Returns the covered area. More...
 
template<typename Stream >
void dumpArea (Stream &&out) const
 Output the owned area into an output stream. More...
 

Protected Member Functions

Partition_t const * findPartWithKey (double key) const
 Returns the only partition which could contain the specified key. More...
 
void initParts ()
 Performs initialization on the specified subpartition list. More...
 
- Protected Member Functions inherited from geo::part::PartitionContainer< Data >
std::size_t size () const
 Returns the number of contained subpartitions. More...
 
virtual Subpartitions_t const & parts () const override
 Returns a list of the subpartitions owned. More...
 
 PartitionContainer (Area_t const &area, Subpartitions_t &&subpartitions, Data_t *defData=nullptr)
 Constructor: sets the partition. More...
 
virtual Partition_t const * findPart (double w, double d) const =0
 Returns the only partition which could contain the specified width. More...
 
virtual std::string doDescribe (std::string indent, std::string firstIndent) const override
 Describes this and each of the subpartitions. More...
 
virtual std::string describeIntro () const
 Introduction to the description of the subpartitions. More...
 
- Protected Member Functions inherited from geo::part::PartitionBase
std::string describeArea (std::string indent, std::string firstIndent) const
 Returns a description of the partition area. More...
 

Protected Attributes

Sorter_t sorter
 Object used for sorting and binary search. More...
 
- Protected Attributes inherited from geo::part::PartitionContainer< Data >
Subpartitions_t myParts
 List of subpartitions. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from geo::part::Partition< Data >
template<typename Pred >
static void walk (Partition_t const *start, Pred &&pred)
 
- Static Protected Attributes inherited from geo::part::Partition< Data >
static Subpartitions_t const NoSubparts
 Subpartitions (if any). More...
 

Detailed Description

template<typename Data, typename Sorter>
class geo::part::SortedPartition< Data, Sorter >

Partition of area sorted across a dimension.

Template Parameters
Datatype of data contained in the partition
Sortertype of functor providing comparison of partitions

The sorter is a functor containing comparison functions. It must be compatible with both std::sort() and std::lower_bound() functions. The former requirement implies that the sorter can compare two constant pointers to partitions. The latter also implies that the sorter can compare a constant pointer to partition to a "key" (a real number), and vice versa. The meaning of this comparison is not prescribed; existing implementations interpret that value as a width or depth coordinate.

A copy of the sorter is kept in this partition.

Definition at line 396 of file Partitions.h.

Member Typedef Documentation

template<typename Data , typename Sorter >
using geo::part::SortedPartition< Data, Sorter >::Area_t = typename Partition_t::Area_t

Definition at line 405 of file Partitions.h.

template<typename Data , typename Sorter >
using geo::part::SortedPartition< Data, Sorter >::Base_t = PartitionContainer<Data>

Base class.

Definition at line 399 of file Partitions.h.

template<typename Data , typename Sorter >
using geo::part::SortedPartition< Data, Sorter >::Data_t = typename Partition_t::Data_t

Definition at line 404 of file Partitions.h.

template<typename Data , typename Sorter >
using geo::part::SortedPartition< Data, Sorter >::Partition_t = Partition<Data>

Base type of the partition.

Definition at line 400 of file Partitions.h.

template<typename Data , typename Sorter >
using geo::part::SortedPartition< Data, Sorter >::Sorter_t = Sorter

Type of sorter being used.

Definition at line 401 of file Partitions.h.

template<typename Data , typename Sorter >
using geo::part::SortedPartition< Data, Sorter >::Subpartitions_t = typename Base_t::Subpartitions_t

Definition at line 406 of file Partitions.h.

Constructor & Destructor Documentation

template<typename Data , typename Sorter >
geo::part::SortedPartition< Data, Sorter >::SortedPartition ( Area_t const &  area,
Subpartitions_t &&  subpartitions,
Data_t defData = nullptr,
Sorter_t  sorter = {} 
)
inline

Constructor: sets the partition.

Parameters
areaoverall area covered
subpartitionslist of subpartitions (pointers)
defDatadatum to be returned for points not covered by subpartitions
sorterinstance of the sorter to be used

The subpartitions will be moved from the argument and will be sorted using the comparison contained in the sorter. Note that this will invalidate existing pointers to the sub-partitions.

It is required and assumed that the subpartitions do not overlap and that the points covered by them are a subset of area. Neither of theses requirements is checked.

Definition at line 424 of file Partitions.h.

428  {}
429  )
430  : Base_t(area, std::move(subpartitions), defData), sorter(sorter)
431  { initParts(); }
void initParts()
Performs initialization on the specified subpartition list.
Definition: Partitions.h:895
def move(depos, offset)
Definition: depos.py:107
Area_t const & area() const
Returns the covered area.
Definition: Partitions.h:56
Sorter_t sorter
Object used for sorting and binary search.
Definition: Partitions.h:435
PartitionContainer< Data > Base_t
Base class.
Definition: Partitions.h:399

Member Function Documentation

template<typename Data , typename Sorter >
auto geo::part::SortedPartition< Data, Sorter >::findPartWithKey ( double  key) const
protected

Returns the only partition which could contain the specified key.

Definition at line 884 of file Partitions.h.

886 {
887  auto pbegin = Base_t::parts().cbegin();
888  auto iPart = std::upper_bound(pbegin, Base_t::parts().cend(), key, sorter);
889  return (iPart == pbegin)? nullptr: (--iPart)->get();
890 } // geo::part::SortedPartition<>::findPartWithKey()
decltype(auto) constexpr cend(T &&obj)
ADL-aware version of std::cend.
Definition: StdUtils.h:87
def key(type, name=None)
Definition: graph.py:13
virtual Subpartitions_t const & parts() const override
Returns a list of the subpartitions owned.
Definition: Partitions.h:343
Sorter_t sorter
Object used for sorting and binary search.
Definition: Partitions.h:435
template<typename Data , typename Sorter >
void geo::part::SortedPartition< Data, Sorter >::initParts ( )
protected

Performs initialization on the specified subpartition list.

Definition at line 895 of file Partitions.h.

895  {
896  /*
897  * Initialization tasks:
898  * - ensure that the parts are sorted by increasing depth
899  *
900  */
902 
903 } // geo::part::SortedPartition<>::initParts()
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
Subpartitions_t myParts
List of subpartitions.
Definition: Partitions.h:337
Sorter_t sorter
Object used for sorting and binary search.
Definition: Partitions.h:435
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72

Member Data Documentation

template<typename Data , typename Sorter >
Sorter_t geo::part::SortedPartition< Data, Sorter >::sorter
protected

Object used for sorting and binary search.

Definition at line 435 of file Partitions.h.


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