aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/fef/symmetrictable.cpp
blob: 5877f336cc7c1ae9227c4b3820685ea147343ce0 (plain) (blame)
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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "symmetrictable.h"

namespace search::fef {

SymmetricTable::SymmetricTable() :
    _backingTable(),
    _size(),
    _table(nullptr),
    _max(0)
{
}

SymmetricTable::SymmetricTable(const SymmetricTable & table) :
    _backingTable(table._backingTable),
    _size(_backingTable.size()/2),
    _table(&_backingTable[_size]),
    _max(table.max())
{
}

SymmetricTable & SymmetricTable::operator=(const SymmetricTable & rhs)
{
    if (&rhs != this) {
        SymmetricTable n(rhs);
        swap(n);
    }
    return *this;
}

SymmetricTable::SymmetricTable(const Table & table) :
    _backingTable(table.size()*2 - 1),
    _size(_backingTable.size()/2),
    _table(&_backingTable[_size]),
    _max(table.max())
{
    _table[0] = table[0];
    for(int i(1); i <= _size; i++) {
        _table[i] = table[i];
        _table[-i] = -table[i];
    }
}

SymmetricTable::~SymmetricTable() = default;

}