view anagram/support/bitmap.h @ 11:3aa0f5a02342

Remove unused variable; fix what it was supposed to be doing. (and document it a bit for the next time through here)
author David A. Holland
date Tue, 31 May 2022 00:54:12 -0400
parents 13d2b8934445
children
line wrap: on
line source

/*
 * AnaGram, A System for Syntax Directed Programming
 * Copyright 1993-2000 Parsifal Software. All Rights Reserved.
 * See the file COPYING for license and usage terms.
 *
 * bitmap.h
 */

#ifndef BITMAP_H
#define BITMAP_H

#include <string.h>
#include "port.h"

#include "data.h" // sigh... XXX   (for n_chars)
#include "pointer.h"


class Bitmap {
protected:
  unsigned nChars;
  unsigned int nBits;

  ArrayPointer<unsigned char> map;

public:
  Bitmap(int n) : nChars((n+7)/8), nBits(n), map(new unsigned char[nChars]) {
    memset(map, 0, nChars);
  }
  virtual ~Bitmap() {}
  virtual int setBit(int x);
  virtual int getBit(int x);
  virtual int list(int *x);
  virtual Bitmap &setRange(unsigned first, unsigned last);
  Bitmap &operator |= (const Bitmap &b);
  Bitmap &operator &= (const Bitmap &b);
  Bitmap &operator -= (const Bitmap &b);
  Bitmap &operator ~ ();
};

class CharBitmap : public Bitmap {
public:
  CharBitmap() : Bitmap(n_chars) {}
  CharBitmap(const Bitmap &b) : Bitmap(b) {}
  virtual int setBit(int x);
  virtual int getBit(int x);
  virtual int list(int *x);
#ifdef _MSC_VER
  virtual Bitmap &setRange(unsigned first, unsigned last);
#else
  virtual CharBitmap &setRange(unsigned first, unsigned last);
#endif
  void blurCase();
  void blurCase(int);
};


#endif /* BITMAP_H */