summaryrefslogtreecommitdiffstats
path: root/debian/htdig/htdig-3.2.0b6/htsearch/ResultList.cc
blob: 969c7bb002d706b16c327f06d346558eee227396 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
//
// ResultList.cc
//
// ResultList: A Dictionary indexed on the document id that holds
//             documents found for a search.
//
// Part of the ht://Dig package   <http://www.htdig.org/>
// Copyright (c) 1995-2004 The ht://Dig Group
// For copyright details, see the file COPYING in your distribution
// or the GNU Library General Public License (LGPL) version 2 or later
// <http://www.gnu.org/copyleft/lgpl.html>
//
// $Id: ResultList.cc,v 1.10 2004/05/28 13:15:24 lha Exp $
//

#ifdef HAVE_CONFIG_H
#include "htconfig.h"
#endif /* HAVE_CONFIG_H */

#include "ResultList.h"
#include "htString.h"


//*****************************************************************************
// ResultList::ResultList()
//
ResultList::ResultList()
{
    isIgnore = 0;
}


//*****************************************************************************
// ResultList::~ResultList()
//
ResultList::~ResultList()
{
    //Destroy();
}


//*****************************************************************************
//
void
ResultList::add(DocMatch *dm)
{
    String	t;
    t << dm->GetId();
    Add(t, dm);
}


//*****************************************************************************
//
DocMatch *
ResultList::find(int id) const
{
    String	t;
    t << id;
    return (DocMatch *) Find(t);
}


//*****************************************************************************
//
DocMatch *
ResultList::find(char *id) const
{
    return (DocMatch *) Find(id);
}


//*****************************************************************************
//
void
ResultList::remove(int id)
{
    String	t;
    t << id;
    Remove(t);
}


//*****************************************************************************
//
int
ResultList::exists(int id) const
{
    String	t;
    t << id;
    return Exists(t);
}


//*****************************************************************************
//
HtVector *
ResultList::elements()
{
    HtVector	*list = new HtVector(Count() + 1);
    char	*id;

    Start_Get();
    while ((id = Get_Next()))
    {
	list->Add(Find(id));
    }
    return list;
}

void
ResultList::SetWeight(double weight)
{
	HtVector *els = elements();
	for(int i = 0; i < els->Count(); i++)
	{
		DocMatch *match = (DocMatch *)(*els)[i];
		match->SetWeight(weight);
	}
	els->Release();
}


ResultList::ResultList(const ResultList &other)
{
	DictionaryCursor c;
	isIgnore = other.isIgnore;
	other.Start_Get(c);
	DocMatch *match = (DocMatch *)other.Get_NextElement(c);
	while(match)
	{
		add(new DocMatch(*match));
		match = (DocMatch *)other.Get_NextElement(c);
	}
}

void
ResultList::Dump() const
{
	cerr << "ResultList {" << endl;
	cerr << "Ignore: " << isIgnore << " Count: " << Count() << endl;
	DictionaryCursor c;
	Start_Get(c);
	DocMatch *match = (DocMatch *)Get_NextElement(c);
	while(match)
	{
		match->Dump();
		match = (DocMatch *)Get_NextElement(c);
	}
	cerr << "}" << endl;
}