FMI Ticket System
| Kamen Mladenov | FMI Computer Science Year 1 Group 6 | Project 1 | Project Topic 4 |
Public Member Functions | List of all members
OrderedList< T > Class Template Reference

Inherits List, but contains it's elements in a sorted manner. More...

#include <OrderedList.hpp>

Inheritance diagram for OrderedList< T >:
List< T >

Public Member Functions

 OrderedList (const T *elements, unsigned elementsCount)
 
void add (T element)=delete
 
void insertAt (T element, unsigned index)=delete
 
void insert (T element)
 Inserts an element at a sorted position. More...
 
- Public Member Functions inherited from List< T >
 List (const T *elements, unsigned elementsCount)
 Copies all elements in given array.
 
void add (const T &element)
 Adds an element. More...
 
void insertAt (const T &element, unsigned index)
 Inserts element at given index. More...
 
bool removeAt (unsigned index)
 Removes element at index. More...
 
unsigned findIndex (const T &element) const
 Finds the index of element. More...
 
bool contain (const T &element) const
 
T & operator[] (unsigned index)
 Returns reference to element at index.
 
const T & operator[] (unsigned index) const
 Returns constant reference to element at index.
 
List< T > & operator+= (const List< T > other)
 Appends elements from other list.
 
std::istream & read (std::istream &istr)
 Reads from stream. More...
 
std::ostream & write (std::ostream &ostr) const
 Writes to stream. More...
 
unsigned get_length () const
 Returns the length. More...
 
unsigned get_count () const
 Returns the count. More...
 
List & operator= (const List &other)
 
 List (const List &other)
 
 List (List &&other)
 
List & operator= (List &&other)
 

Additional Inherited Members

- Protected Member Functions inherited from List< T >
void resize ()
 
void free ()
 
void copyFrom (const List &other)
 
- Protected Attributes inherited from List< T >
T * elements
 
unsigned length
 
unsigned count
 

Detailed Description

template<typename T>
class OrderedList< T >

Inherits List, but contains it's elements in a sorted manner.

Warning
Outside those defined in List, insert() requires the type to have defined a "compare" of functions.
See also
insert()

Member Function Documentation

◆ add()

template<typename T >
void OrderedList< T >::add ( T  element)
delete
Warning
Function is deleted, use insert() instead
See also
insert()

◆ insert()

template<typename T >
void OrderedList< T >::insert ( T  element)

Inserts an element at a sorted position.

Warning
The function depends on the type having a function "compare" defined, which takes two elements and returns a number <0 if elem1 < elem2, >0 if elem1 > elem2, 0 if elem1 == elem2
Note
Insertion is done linearly

◆ insertAt()

template<typename T >
void OrderedList< T >::insertAt ( T  element,
unsigned  index 
)
delete
Warning
Function is deleted, use insert() instead
See also
insert()

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