mdds
Classes | Public Types | Public Member Functions | List of all members
mdds::rectangle_set< _Key, _Value > Class Template Reference

Classes

class  search_result
 

Public Types

typedef _Key key_type
 
typedef _Value value_type
 
typedef inner_type::search_result_type search_result_type
 

Public Member Functions

 rectangle_set (const rectangle_set &r)
 
rectangle_setoperator= (const rectangle_set &r)
 
bool operator== (const rectangle_set &r) const
 
bool operator!= (const rectangle_set &r) const
 
bool insert (key_type x1, key_type y1, key_type x2, key_type y2, value_type data)
 
bool search (key_type x, key_type y, search_result_type &result)
 
search_result search (key_type x, key_type y)
 
void remove (value_type data)
 
void clear ()
 
size_t size () const
 
bool empty () const
 

Member Function Documentation

◆ clear()

template<typename _Key , typename _Value >
void mdds::rectangle_set< _Key, _Value >::clear ( )

Clear all rectangles stored in the set.

◆ empty()

template<typename _Key , typename _Value >
bool mdds::rectangle_set< _Key, _Value >::empty ( ) const

Check whether or not the set is empty.

Returns
true if the set is empty, false otherwise.

◆ insert()

template<typename _Key , typename _Value >
bool mdds::rectangle_set< _Key, _Value >::insert ( key_type  x1,
key_type  y1,
key_type  x2,
key_type  y2,
value_type  data 
)

Insert a new rectangle (and data associated with it) into the set. Note that insertion of duplicate data instance is not allowed. A data is considered a duplicate if its pointer value is identical to one of the data instances already stored within. Also note that the end point of a rectangle is non-inclusive; a rectangle of (x1,y1) - (x2,y2) means that the rectangle spans x1 <= x < x2 and y1 <= y < y2.

Parameters
x1lower x coordinate of the rectangle. Inclusive.
y1lower y coordinate of the rectangle. Inclusive.
x2upper x coordinate of the rectangle. Non-inclusive.
y2upper y coordinate of the rectangle. Non-inclusive.
datapointer to data instance associated with this rectangle. Note that the caller is responsible for managing the life cycle of the data instance.
Returns
true if a rectangle successfully inserted, false otherwise.

◆ operator==()

template<typename _Key , typename _Value >
bool mdds::rectangle_set< _Key, _Value >::operator== ( const rectangle_set< _Key, _Value > &  r) const

Equality between two instances of rectangle_set is evaluated based on the stored rectangle instances; their pointer values and geometries.

◆ remove()

template<typename _Key , typename _Value >
void mdds::rectangle_set< _Key, _Value >::remove ( value_type  data)

Remove a rectangle instance pointed to by a given pointer.

Parameters
datapointer that points to the rectangle instance you wish to remove from the set.

◆ search() [1/2]

template<typename _Key , typename _Value >
bool mdds::rectangle_set< _Key, _Value >::search ( key_type  x,
key_type  y,
search_result_type &  result 
)

Search and collect all rectangles that contains a given point.

Parameters
xx coordinate of a query point.
yy coordinate of a query point.
resultarray of pointers to rectangle instances.
Returns
true if the search is successful, false otherwise.

◆ search() [2/2]

template<typename _Key , typename _Value >
search_result mdds::rectangle_set< _Key, _Value >::search ( key_type  x,
key_type  y 
)

Search and collect all rectangles containing a given point.

Parameters
xx coordinate of a query point.
yy coordinate of a query point.
Returns
object containing the result of the search, which can be accessed via iterator.

◆ size()

template<typename _Key , typename _Value >
size_t mdds::rectangle_set< _Key, _Value >::size ( ) const

Return the number of rectangles currently stored in the set.

Returns
number of stored rectangles.