aboutsummaryrefslogtreecommitdiff
path: root/cpp08/ex01/span.hpp
blob: 6b72fb5ac9ee4d8bf6316b2c7ff169496956736e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   span.hpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: charles <charles.cabergs@gmail.com>        +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/15 06:55:07 by charles           #+#    #+#             */
/*   Updated: 2020/12/15 12:22:31 by cacharle         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#ifndef SPAN_HPP
# define SPAN_HPP

# include <algorithm>

class Span
{
public:
    Span();
    Span(Span const& other);
    void operator=(Span const& other);
    ~Span();

    Span(unsigned int n);

    void addNumber(int x);

    template <typename InputIterator>
    void addNumber(InputIterator begin, InputIterator end)
    {
        for (; begin != end; ++begin)
            addNumber(*begin);
    }

    int shortestSpan() const;
    int longestSpan()  const;

private:
    int*         m_under;
    unsigned int m_size;
    unsigned int m_fillIndex;

    void setupSpan() const;
};

#endif