File: CharCache.H

package info (click to toggle)
dxpc 3.9.2-4
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,164 kB
  • ctags: 1,252
  • sloc: cpp: 12,036; sh: 2,823; makefile: 77
file content (37 lines) | stat: -rw-r--r-- 943 bytes parent folder | download | duplicates (3)
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
#ifndef CharCache_H
# define CharCache_H

// CharCache is a counterpart of IntCache that is
// optimized for use in compressing text composed
// of 8-bit characters.  (There used to be an
// abstract class Cache from which CharCache and
// IntCache were derived.  This has been eliminated,
// however, since the use of virtual functions
// increased the size of each CharCache by 50%
// (not a good thing when TextCompressor has an
// array of several thousand CharCaches :-)

class CharCache
{
  public:
    CharCache():length_(0)
    {
    }
     ~CharCache()
    {
    }
    unsigned int getSize() const
    {
        return (unsigned int) length_;
    }
    int lookup(unsigned char value, unsigned int &index);
    unsigned int get(unsigned int i);
    void insert(unsigned char value);

  private:
    unsigned char length_;
    unsigned char buffer_[7];   // limit to 7 chars so object will fit in 8 bytes

};

#endif /* CharCache_H */