DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: F T

⟦7c4e78e15⟧ TextFile

    Length: 5428 (0x1534)
    Types: TextFile
    Names: »FPlex.hP«

Derivation

└─⟦a05ed705a⟧ Bits:30007078 DKUUG GNU 2/12/89
    └─⟦cc8755de2⟧ »./libg++-1.36.1.tar.Z« 
        └─⟦23757c458⟧ 
            └─⟦this⟧ »libg++/g++-include/FPlex.hP« 

TextFile

// This may look like C code, but it is really -*- C++ -*-
/* 
Copyright (C) 1988 Free Software Foundation
    written by Doug Lea (dl@rocky.oswego.edu)
    based on code by Marc Shapiro (shapiro@sor.inria.fr)

This file is part of GNU CC.

GNU CC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.  No author or distributor
accepts responsibility to anyone for the consequences of using it
or for whether it serves any particular purpose or works at all,
unless he says so in writing.  Refer to the GNU CC General Public
License for full details.

Everyone is granted permission to copy, modify and redistribute
GNU CC, but only under the conditions described in the
GNU CC General Public License.   A copy of this license is
supposed to have been given to you along with GNU CC so you
can know your rights and responsibilities.  It should be in a
file named COPYING.  Among other things, the copyright notice
and this notice must be preserved on all copies.  
*/

#ifndef _<T>FPlex_h
#pragma once
#define _<T>FPlex_h 1

#include "<T>.Plex.h"

class <T>FPlex : public <T>Plex
{
public:
                   <T>FPlex();                 // set low = 0;
                                               // fence = 0;
                                               // csize = default

                   <T>FPlex(int maxsize);      // low = 0; 
                                               // fence = 0;
                                               // csize = maxsize

                   <T>FPlex(int lo,            // low = lo; 
                            int maxsize);      // fence=lo
                                               // csize = maxsize

                   <T>FPlex(int lo,            // low = lo
                            int hi,            // fence = hi+1
                            const <T&> initval,// fill with initval,
                            int maxsize = 0);  // csize = maxsize
                                               // or fence - lo if 0

                   <T>FPlex(<T>FPlex&);   // X(X&)

                   ~<T>FPlex();

  void             operator= (<T>FPlex&);

// virtuals

  <T>&             high_element ();
  <T>&             low_element ();

  Pix              first();
  Pix              last();
  void             prev(Pix& ptr);
  void             next(Pix& ptr);
  int              owns(Pix p);
  <T>&             operator () (Pix p);

  int              low(); 
  int              high();
  int              valid(int idx);
  void             prev(int& idx);
  void             next(int& x);
  <T>&             operator [] (int index);
    
  int              Pix_to_index(Pix p);
  Pix              index_to_Pix(int idx);    

  int              can_add_high();
  int              can_add_low();
  int              full();

  int              add_high(const <T&> elem);
  int              del_high ();
  int              add_low (const <T&> elem);
  int              del_low ();

  void             fill(const <T&> x);
  void             fill(const <T&> x, int from, int to);
  void             clear();
  void             reverse();
  void             append(<T>Plex& a); 
  void             prepend(<T>Plex& a);
    
  int              OK (); 
};


inline  int <T>FPlex::valid (int idx)
{
  return idx >= lo && idx < fnc;
}

inline int <T>FPlex::low()
{
  return lo;
}

inline int <T>FPlex::high()
{
  return fnc - 1;
}

inline Pix  <T>FPlex::first()
{
  return (Pix)(hd-><T>IChunk::first_pointer());
}

inline void  <T>FPlex::prev(Pix&  p)
{
  p = Pix(hd-><T>IChunk::pred((<T>*) p));
}

inline void  <T>FPlex::next(Pix&  p)
{
  p =  Pix(hd-><T>IChunk::succ((<T>*) p));
}

inline Pix <T>FPlex::last()
{
  return Pix(hd-><T>IChunk::last_pointer());
}

inline  int <T>FPlex::full ()
{
  return fnc - lo == csize;
}

inline void <T>FPlex::prev(int& idx)
{
  --idx;
}

inline void <T>FPlex::next(int& idx)
{
  ++idx;
}

inline <T>& <T>FPlex:: operator [] (int idx)
{
  if (idx < lo || idx >= fnc) index_error();
  return *(hd->pointer_to(idx));
}

inline <T>& <T>FPlex:: operator () (Pix p)
{
  return *((<T>*)p);
}

inline  <T>& <T>FPlex::low_element ()
{
  if (empty()) index_error();
  return *(hd->pointer_to(lo));
}

inline  <T>& <T>FPlex::high_element ()
{
  if (empty()) index_error();
  return *(hd->pointer_to(fnc - 1));
}

inline int <T>FPlex::can_add_high()
{
  return hd->can_grow_high();
}

inline int <T>FPlex::can_add_low()
{
  return hd->can_grow_low();
}

inline int <T>FPlex::add_high(const <T&> elem)
{
  if (!can_add_high()) full_error();
  record_change();
  *((hd-><T>IChunk::grow_high())) = elem;
  return fnc++;
}

inline  int <T>FPlex::del_high ()
{
  if (empty()) empty_error();
  record_change();
  hd-><T>IChunk::shrink_high();
  return --fnc - 1;
}

inline  int <T>FPlex::add_low (const <T&> elem)
{
  if (!can_add_low()) full_error();
  record_change();
  *((hd-><T>IChunk::grow_low())) = elem;
  return --lo;
}

inline  int <T>FPlex::del_low ()
{
  if (empty()) empty_error();
  record_change();
  hd-><T>IChunk::shrink_low();
  return ++lo;
}

inline  int <T>FPlex::owns (Pix p)
{
  return hd->actual_pointer(p);
}

inline  int <T>FPlex::Pix_to_index(Pix p)
{
  if (!hd->actual_pointer((<T>*)p)) index_error();
  return hd->index_of((<T>*)p);
}

inline  Pix <T>FPlex::index_to_Pix(int idx)
{
  if (idx < lo || idx >= fnc) index_error();
  return Pix(hd->pointer_to(idx));
}

inline <T>FPlex::~<T>FPlex() {}

#endif