LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | List of all members
lsst::afw::table::SortedCatalogT< RecordT > Class Template Reference

Custom catalog class for record/table subclasses that are guaranteed to have an ID, and should generally be sorted by that ID. More...

#include <fwd.h>

Inheritance diagram for lsst::afw::table::SortedCatalogT< RecordT >:
lsst::afw::table::CatalogT< RecordT > lsst::afw::table::ExposureCatalogT< RecordT >

Public Types

typedef RecordT Record
 
typedef Record::Table Table
 
typedef Base::iterator iterator
 
typedef Base::const_iterator const_iterator
 
- Public Types inherited from lsst::afw::table::CatalogT< RecordT >
typedef RecordT Record
 
typedef Record::Table Table
 
typedef Record::ColumnView ColumnView
 
typedef RecordT value_type
 
typedef RecordT & reference
 
typedef boost::shared_ptr
< RecordT > 
pointer
 
typedef Internal::size_type size_type
 
typedef Internal::difference_type difference_type
 
typedef CatalogIterator
< typename Internal::iterator > 
iterator
 
typedef CatalogIterator
< typename
Internal::const_iterator > 
const_iterator
 

Public Member Functions

bool isSorted () const
 Return true if the vector is in ascending ID order. More...
 
void sort ()
 Sort the vector in-place by ID. More...
 
 SortedCatalogT (boost::shared_ptr< Table > const &table=boost::shared_ptr< Table >())
 Construct a vector from a table (or nothing). More...
 
 SortedCatalogT (Schema const &schema)
 Construct a vector from a schema, creating a table with Table::make(schema). More...
 
template<typename InputIterator >
 SortedCatalogT (boost::shared_ptr< Table > const &table, InputIterator first, InputIterator last, bool deep=false)
 Construct a vector from a table and an iterator range. More...
 
template<typename OtherRecordT >
 SortedCatalogT (SortedCatalogT< OtherRecordT > const &other)
 Shallow copy constructor from a container containing a related record type. More...
 
SortedCatalogT< RecordT > subset (ndarray::Array< bool const, 1 > const &mask) const
 Return the subset of a catalog corresponding to the True values of the given mask array. More...
 
SortedCatalogT subset (std::ptrdiff_t startd, std::ptrdiff_t stopd, std::ptrdiff_t step) const
 Shallow copy a subset of another SortedCatalog. Mostly here for use from python. More...
 
iterator find (RecordId id)
 Return an iterator to the record with the given ID. More...
 
const_iterator find (RecordId id) const
 Return an iterator to the record with the given ID. More...
 
- Public Member Functions inherited from lsst::afw::table::CatalogT< RecordT >
boost::shared_ptr< TablegetTable () const
 Return the table associated with the catalog. More...
 
Schema getSchema () const
 Return the schema associated with the catalog's table. More...
 
 CatalogT (boost::shared_ptr< Table > const &table=boost::shared_ptr< Table >())
 Construct a catalog from a table (or nothing). More...
 
 CatalogT (Schema const &schema)
 Construct a catalog from a schema, creating a table with Table::make(schema). More...
 
template<typename InputIterator >
 CatalogT (boost::shared_ptr< Table > const &table, InputIterator first, InputIterator last, bool deep=false)
 Construct a catalog from a table and an iterator range. More...
 
 CatalogT (CatalogT const &other)
 Shallow copy constructor. More...
 
template<typename OtherRecordT >
 CatalogT (CatalogT< OtherRecordT > const &other)
 Shallow copy constructor from a container containing a related record type. More...
 
CatalogToperator= (CatalogT const &other)
 Shallow assigment. More...
 
CatalogT< RecordT > subset (ndarray::Array< bool const, 1 > const &mask) const
 Return the subset of a catalog corresponding to the True values of the given mask array. More...
 
CatalogT< RecordT > subset (std::ptrdiff_t startd, std::ptrdiff_t stopd, std::ptrdiff_t step) const
 Returns a shallow copy of a subset of this Catalog. The arguments correspond to python's slice() syntax. More...
 
void writeFits (std::string const &filename, std::string const &mode="w", int flags=0) const
 Write a FITS binary table to a regular file. More...
 
void writeFits (fits::MemFileManager &manager, std::string const &mode="w", int flags=0) const
 Write a FITS binary table to a RAM file. More...
 
void writeFits (fits::Fits &fitsfile, int flags=0) const
 Write a FITS binary table to an open file object. More...
 
ColumnView getColumnView () const
 Return a ColumnView of this catalog's records. More...
 
bool isContiguous () const
 Return true if all records are contiguous. More...
 
bool empty () const
 Return true if the catalog has no records. More...
 
size_type size () const
 Return the number of elements in the catalog. More...
 
size_type max_size () const
 Return the maximum number of elements allowed in a catalog. More...
 
size_type capacity () const
 Return the capacity of the catalog. More...
 
void reserve (size_type n)
 Increase the capacity of the catalog to the given size. More...
 
reference operator[] (size_type i) const
 Return the record at index i. More...
 
reference at (size_type i) const
 Return the record at index i (throws std::out_of_range). More...
 
reference front () const
 Return the first record. More...
 
reference back () const
 Return the last record. More...
 
boost::shared_ptr< RecordT > const get (size_type i) const
 Return a pointer to the record at index i. More...
 
void set (size_type i, boost::shared_ptr< RecordT > const &p)
 Set the record at index i to a pointer. More...
 
template<typename InputIterator >
void assign (InputIterator first, InputIterator last, bool deep=false)
 Replace the contents of the table with an iterator range. More...
 
void push_back (Record const &r)
 Add a copy of the given record to the end of the catalog. More...
 
void push_back (boost::shared_ptr< RecordT > const &p)
 Add the given record to the end of the catalog without copying. More...
 
boost::shared_ptr< RecordT > addNew ()
 Create a new record, add it to the end of the catalog, and return a pointer to it. More...
 
void pop_back ()
 Remove the last record in the catalog. More...
 
CatalogT copy () const
 Deep-copy the catalog using a cloned table. More...
 
template<typename InputIterator >
void insert (iterator pos, InputIterator first, InputIterator last, bool deep=false)
 Insert an iterator range into the table. More...
 
template<typename InputIterator >
void insert (SchemaMapper const &mapper, iterator pos, InputIterator first, InputIterator last)
 Insert a range of records into the catalog by copying them with a SchemaMapper. More...
 
iterator insert (iterator pos, Record const &r)
 Insert a copy of the given record at the given position. More...
 
iterator insert (iterator pos, boost::shared_ptr< RecordT > const &p)
 Insert the given record at the given position without copying. More...
 
iterator erase (iterator pos)
 Erase the record pointed to by pos, and return an iterator the next record. More...
 
iterator erase (iterator first, iterator last)
 Erase the records in the range [first, last). More...
 
void swap (CatalogT &other)
 Shallow swap of two catalogs. More...
 
void clear ()
 Remove all records from the catalog. More...
 
template<typename T >
bool isSorted (Key< T > const &key) const
 Return true if the catalog is in ascending order according to the given key. More...
 
template<typename Compare >
bool isSorted (Compare cmp) const
 Return true if the catalog is in ascending order according to the given predicate. More...
 
template<typename T >
void sort (Key< T > const &key)
 Sort the catalog in-place by the field with the given key. More...
 
template<typename Compare >
void sort (Compare cmp)
 Sort the catalog in-place by the field with the given predicate. More...
 
template<typename T >
CatalogT< RecordT >::iterator find (typename Field< T >::Value const &value, Key< T > const &key)
 
template<typename T >
CatalogT< RecordT >::const_iterator find (typename Field< T >::Value const &value, Key< T > const &key) const
 
template<typename T >
CatalogT< RecordT >::iterator lower_bound (typename Field< T >::Value const &value, Key< T > const &key)
 
template<typename T >
CatalogT< RecordT >::const_iterator lower_bound (typename Field< T >::Value const &value, Key< T > const &key) const
 
template<typename T >
CatalogT< RecordT >::iterator upper_bound (typename Field< T >::Value const &value, Key< T > const &key)
 
template<typename T >
CatalogT< RecordT >::const_iterator upper_bound (typename Field< T >::Value const &value, Key< T > const &key) const
 
template<typename T >
std::pair< typename CatalogT
< RecordT >::iterator,
typename CatalogT< RecordT >
::iterator
equal_range (typename Field< T >::Value const &value, Key< T > const &key)
 
template<typename T >
std::pair< typename CatalogT
< RecordT >::const_iterator,
typename CatalogT< RecordT >
::const_iterator
equal_range (typename Field< T >::Value const &value, Key< T > const &key) const
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
template<typename T >
iterator find (typename Field< T >::Value const &value, Key< T > const &key)
 Return an iterator to the record with the given value. More...
 
template<typename T >
const_iterator find (typename Field< T >::Value const &value, Key< T > const &key) const
 Return an iterator to the record with the given value. More...
 
template<typename T >
iterator lower_bound (typename Field< T >::Value const &value, Key< T > const &key)
 Performed binary searches on sorted fields. More...
 
template<typename T >
const_iterator lower_bound (typename Field< T >::Value const &value, Key< T > const &key) const
 Performed binary searches on sorted fields. More...
 
template<typename T >
iterator upper_bound (typename Field< T >::Value const &value, Key< T > const &key)
 Performed binary searches on sorted fields. More...
 
template<typename T >
const_iterator upper_bound (typename Field< T >::Value const &value, Key< T > const &key) const
 Performed binary searches on sorted fields. More...
 
template<typename T >
std::pair< iterator, iteratorequal_range (typename Field< T >::Value const &value, Key< T > const &key)
 Performed binary searches on sorted fields. More...
 
template<typename T >
std::pair< const_iterator,
const_iterator
equal_range (typename Field< T >::Value const &value, Key< T > const &key) const
 Performed binary searches on sorted fields. More...
 
InternalgetInternal ()
 Return a reference to the internal vector-of-shared_ptr. More...
 
Internal const & getInternal () const
 Return a reference to the internal vector-of-shared_ptr. More...
 

Static Public Member Functions

static SortedCatalogT readFits (std::string const &filename, int hdu=0, int flags=0)
 Read a FITS binary table from a regular file. More...
 
static SortedCatalogT readFits (fits::MemFileManager &manager, int hdu=0, int flags=0)
 Read a FITS binary table from a RAM file. More...
 
static SortedCatalogT readFits (fits::Fits &fitsfile, int flags=0)
 Read a FITS binary table from a file object already at the correct extension. More...
 
- Static Public Member Functions inherited from lsst::afw::table::CatalogT< RecordT >
static CatalogT readFits (std::string const &filename, int hdu=0, int flags=0)
 Read a FITS binary table from a regular file. More...
 
static CatalogT readFits (fits::MemFileManager &manager, int hdu=0, int flags=0)
 Read a FITS binary table from a RAM file. More...
 
static CatalogT readFits (fits::Fits &fitsfile, int flags=0)
 Read a FITS binary table from a file object already at the correct extension. More...
 

Protected Member Functions

 SortedCatalogT (Base const &other)
 

Private Types

typedef CatalogT< RecordT > Base
 

Detailed Description

template<typename RecordT>
class lsst::afw::table::SortedCatalogT< RecordT >

Custom catalog class for record/table subclasses that are guaranteed to have an ID, and should generally be sorted by that ID.

For a record/table pair to be used with SortedCatalogT, the table class must provide a static getIdKey() member function that returns the key to the ID field.

Definition at line 55 of file fwd.h.

Member Typedef Documentation

template<typename RecordT >
typedef CatalogT<RecordT> lsst::afw::table::SortedCatalogT< RecordT >::Base
private

Definition at line 42 of file SortedCatalog.h.

template<typename RecordT >
typedef Base::const_iterator lsst::afw::table::SortedCatalogT< RecordT >::const_iterator

Definition at line 49 of file SortedCatalog.h.

template<typename RecordT >
typedef Base::iterator lsst::afw::table::SortedCatalogT< RecordT >::iterator

Definition at line 48 of file SortedCatalog.h.

template<typename RecordT >
typedef RecordT lsst::afw::table::SortedCatalogT< RecordT >::Record

Definition at line 45 of file SortedCatalog.h.

template<typename RecordT >
typedef Record::Table lsst::afw::table::SortedCatalogT< RecordT >::Table

Definition at line 46 of file SortedCatalog.h.

Constructor & Destructor Documentation

template<typename RecordT >
lsst::afw::table::SortedCatalogT< RecordT >::SortedCatalogT ( boost::shared_ptr< Table > const &  table = boost::shared_ptr< Table >())
inlineexplicit

Construct a vector from a table (or nothing).

A vector with no table is considered invalid; a valid table must be assigned to it before it can be used.

Definition at line 80 of file SortedCatalog.h.

80 : Base(table) {}
template<typename RecordT >
lsst::afw::table::SortedCatalogT< RecordT >::SortedCatalogT ( Schema const &  schema)
inlineexplicit

Construct a vector from a schema, creating a table with Table::make(schema).

Definition at line 83 of file SortedCatalog.h.

83 : Base(schema) {}
afw::table::Schema schema
Definition: GaussianPsf.cc:41
template<typename RecordT >
template<typename InputIterator >
lsst::afw::table::SortedCatalogT< RecordT >::SortedCatalogT ( boost::shared_ptr< Table > const &  table,
InputIterator  first,
InputIterator  last,
bool  deep = false 
)
inline

Construct a vector from a table and an iterator range.

If deep is true, new records will be created using table->copyRecord before being inserted. If deep is false, records will be not be copied, but they must already be associated with the given table. The table itself is never deep-copied.

The iterator must dereference to a record reference or const reference rather than a pointer, but should be implicitly convertible to a record pointer as well (see CatalogIterator).

Definition at line 96 of file SortedCatalog.h.

96  :
97  Base(table, first, last, deep)
98  {}
template<typename RecordT >
template<typename OtherRecordT >
lsst::afw::table::SortedCatalogT< RecordT >::SortedCatalogT ( SortedCatalogT< OtherRecordT > const &  other)
inline

Shallow copy constructor from a container containing a related record type.

This conversion only succeeds if OtherRecordT is convertible to RecordT and OtherTable is convertible to Table.

Definition at line 107 of file SortedCatalog.h.

107 : Base(other) {}
template<typename RecordT >
lsst::afw::table::SortedCatalogT< RecordT >::SortedCatalogT ( Base const &  other)
inlineexplicitprotected

Definition at line 164 of file SortedCatalog.h.

164 : Base(other) {}

Member Function Documentation

template<typename RecordT >
iterator lsst::afw::table::SortedCatalogT< RecordT >::find ( RecordId  id)
inline

Return an iterator to the record with the given ID.

Note
The vector must be sorted in ascending ID order before calling find (i.e. isSorted() must be true).

Returns end() if the Record cannot be found.

Definition at line 70 of file SortedCatalog.h.

70 { return this->find(id, Table::getIdKey()); }
iterator find(RecordId id)
Return an iterator to the record with the given ID.
Definition: SortedCatalog.h:70
template<typename RecordT >
const_iterator lsst::afw::table::SortedCatalogT< RecordT >::find ( RecordId  id) const
inline

Return an iterator to the record with the given ID.

Note
The vector must be sorted in ascending ID order before calling find (i.e. isSorted() must be true).

Returns end() if the Record cannot be found.

Definition at line 71 of file SortedCatalog.h.

71 { return this->find(id, Table::getIdKey()); }
iterator find(RecordId id)
Return an iterator to the record with the given ID.
Definition: SortedCatalog.h:70
template<typename RecordT >
bool lsst::afw::table::SortedCatalogT< RecordT >::isSorted ( ) const
inline

Return true if the vector is in ascending ID order.

Definition at line 56 of file SortedCatalog.h.

56 { return this->isSorted(Table::getIdKey()); }
bool isSorted() const
Return true if the vector is in ascending ID order.
Definition: SortedCatalog.h:56
template<typename RecordT >
static SortedCatalogT lsst::afw::table::SortedCatalogT< RecordT >::readFits ( std::string const &  filename,
int  hdu = 0,
int  flags = 0 
)
inlinestatic

Read a FITS binary table from a regular file.

Parameters
[in]filenameName of the file to read.
[in]hduNumber of the "header-data unit" to read (where 1 is the Primary HDU). The default value of 0 is interpreted as "the first HDU with NAXIS != 0".
[in]flagsTable-subclass-dependent bitflags that control the details of how to read the catalog. See e.g. SourceFitsFlags.

Definition at line 118 of file SortedCatalog.h.

118  {
119  return io::FitsReader::apply<SortedCatalogT>(filename, hdu, flags);
120  }
template<typename RecordT >
static SortedCatalogT lsst::afw::table::SortedCatalogT< RecordT >::readFits ( fits::MemFileManager manager,
int  hdu = 0,
int  flags = 0 
)
inlinestatic

Read a FITS binary table from a RAM file.

Parameters
[in]managerObject that manages the memory to be read.
[in]hduNumber of the "header-data unit" to read (where 1 is the Primary HDU). The default value of 0 is interpreted as "the first HDU with NAXIS != 0".
[in]flagsTable-subclass-dependent bitflags that control the details of how to read the catalog. See e.g. SourceFitsFlags.

Definition at line 131 of file SortedCatalog.h.

131  {
132  return io::FitsReader::apply<SortedCatalogT>(manager, hdu, flags);
133  }
template<typename RecordT >
static SortedCatalogT lsst::afw::table::SortedCatalogT< RecordT >::readFits ( fits::Fits fitsfile,
int  flags = 0 
)
inlinestatic

Read a FITS binary table from a file object already at the correct extension.

Parameters
[in]fitsfileFits file object to read from.
[in]flagsTable-subclass-dependent bitflags that control the details of how to read the catalog. See e.g. SourceFitsFlags.

Definition at line 142 of file SortedCatalog.h.

142  {
143  return io::FitsReader::apply<SortedCatalogT>(fitsfile, flags);
144  }
template<typename RecordT >
void lsst::afw::table::SortedCatalogT< RecordT >::sort ( )
inline

Sort the vector in-place by ID.

Definition at line 59 of file SortedCatalog.h.

59 { this->sort(Table::getIdKey()); }
void sort()
Sort the vector in-place by ID.
Definition: SortedCatalog.h:59
template<typename RecordT >
SortedCatalogT<RecordT> lsst::afw::table::SortedCatalogT< RecordT >::subset ( ndarray::Array< bool const, 1 > const &  mask) const
inline

Return the subset of a catalog corresponding to the True values of the given mask array.

The returned array's records are shallow copies, and hence will not in general be contiguous.

Definition at line 151 of file SortedCatalog.h.

151  {
152  return SortedCatalogT(Base::subset(mask));
153  }
CatalogT< RecordT > subset(ndarray::Array< bool const, 1 > const &mask) const
Return the subset of a catalog corresponding to the True values of the given mask array...
Definition: Catalog.h:172
SortedCatalogT(boost::shared_ptr< Table > const &table=boost::shared_ptr< Table >())
Construct a vector from a table (or nothing).
Definition: SortedCatalog.h:80
template<typename RecordT >
SortedCatalogT lsst::afw::table::SortedCatalogT< RecordT >::subset ( std::ptrdiff_t  startd,
std::ptrdiff_t  stopd,
std::ptrdiff_t  step 
) const
inline

Shallow copy a subset of another SortedCatalog. Mostly here for use from python.

Definition at line 159 of file SortedCatalog.h.

159  {
160  return SortedCatalogT(Base::subset(startd, stopd, step));
161  }
CatalogT< RecordT > subset(ndarray::Array< bool const, 1 > const &mask) const
Return the subset of a catalog corresponding to the True values of the given mask array...
Definition: Catalog.h:172
SortedCatalogT(boost::shared_ptr< Table > const &table=boost::shared_ptr< Table >())
Construct a vector from a table (or nothing).
Definition: SortedCatalog.h:80

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