Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
TokenCount.cs
1using System;
2using System.Text;
4
6{
10 [TypeName(TypeNameSerialization.None)]
11 public class TokenCount
12 {
16 public TokenCount()
17 {
18 }
19
25 public TokenCount(string Token, params uint[] DocIndex)
26 {
27 this.Token = Token;
28 this.DocIndex = DocIndex;
29 this.Block = 0;
30 }
31
35 public string Token { get; set; }
36
40 public uint[] DocIndex { get; set; }
41
45 public uint Block { get; set; }
46
50 public override string ToString()
51 {
52 StringBuilder sb = new StringBuilder();
53
54 sb.Append(this.Token);
55 sb.Append(':');
56
57 foreach (uint Index in this.DocIndex)
58 {
59 sb.Append(Index.ToString());
60 sb.Append(' ');
61 }
62
63 sb.Append('(');
64 sb.Append(this.Block.ToString());
65 sb.Append(')');
66
67 return sb.ToString();
68 }
69
71 public override bool Equals(object obj)
72 {
73 int i, c = this.DocIndex.Length;
74
75 if (!(obj is TokenCount Token) ||
76 this.Token != Token.Token ||
77 c != Token.DocIndex.Length ||
78 this.Block != Token.Block)
79 {
80 return false;
81 }
82
83 for (i = 0; i < c; i++)
84 {
85 if (this.DocIndex[i] != Token.DocIndex[i])
86 return false;
87 }
88
89 return true;
90 }
91
93 public override int GetHashCode()
94 {
95 int Result;
96
97 Result = this.Token?.GetHashCode() ?? 0;
98 Result ^= Result << 5 ^ this.Block.GetHashCode();
99
100 if (!(this.DocIndex is null))
101 {
102 foreach (uint Index in this.DocIndex)
103 Result ^= Result << 5 ^ Index.GetHashCode();
104 }
105
106 return Result;
107 }
108 }
109}
Represents a token and a corresponding occurrence count.
Definition: TokenCount.cs:12
TokenCount(string Token, params uint[] DocIndex)
Represents a token and a corresponding occurrence count.
Definition: TokenCount.cs:25
uint Block
Reference is stored in this block in the full-text-search index.
Definition: TokenCount.cs:45
TokenCount()
Represents a token and a corresponding occurrence count.
Definition: TokenCount.cs:16
override string ToString()
Object.ToString()
Definition: TokenCount.cs:50
uint[] DocIndex
Index inside document of each occurrence.
Definition: TokenCount.cs:40
override bool Equals(object obj)
Definition: TokenCount.cs:71
TypeNameSerialization
How the type name should be serialized.