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: T X

⟦7c7a8ef10⟧ TextFile

    Length: 4945 (0x1351)
    Types: TextFile
    Names: »XPlex.hP«

Derivation

└─⟦a05ed705a⟧ Bits:30007078 DKUUG GNU 2/12/89
    └─⟦cc8755de2⟧ »./libg++-1.36.1.tar.Z« 
        └─⟦23757c458⟧ 
            └─⟦this⟧ »libg++/g++-include/XPlex.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>XPlex_h
#pragma once
#define _<T>XPlex_h 1

#include "<T>.Plex.h"

class <T>XPlex: public <T>Plex
{
  <T>IChunk*       ch;           // cached chunk

  void             make_initial_chunks(int up = 1);

  void             cache(int idx);
  void             cache(const <T>* p);

  <T>*             dopred(<T>* p);
  <T>*             dosucc(<T>* p);

public:
                   <T>XPlex();                 // set low = 0;
                                               // fence = 0;
                                               // csize = default

                   <T>XPlex(int ch_size);      // low = 0; 
                                               // fence = 0;
                                               // csize = ch_size

                   <T>XPlex(int lo,            // low = lo; 
                            int ch_size);      // fence=lo
                                               // csize = ch_size

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

                   <T>XPlex( <T>XPlex&);
  
  void             operator= ( <T>XPlex&);

// 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 void <T>XPlex::prev(int& idx)
{
  --idx;
}

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

inline  int <T>XPlex::full ()
{
  return 0;
}

inline int <T>XPlex::can_add_high()
{
  return 1;
}

inline int <T>XPlex::can_add_low()
{
  return 1;
}

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

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

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

inline <T>& <T>XPlex:: operator [] (int idx)
{
  if (!ch->actual_index(idx)) cache(idx);
  return *(ch->pointer_to(idx));
}

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

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

inline  int <T>XPlex::Pix_to_index(Pix p)
{
  if (!ch->actual_pointer(p)) cache(p);
  return ch->index_of(p);
}

inline  Pix <T>XPlex::index_to_Pix(int idx)
{
  if (!ch->actual_index(idx)) cache(idx);
  return (Pix)(ch->pointer_to(idx));
}

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

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

inline void <T>XPlex::prev(Pix& p)
{
  Pix q = Pix(ch-><T>IChunk::pred((<T>*) p));
  p = (q == 0)? Pix(dopred((<T>*) p)) : q;
}

inline void <T>XPlex::next(Pix& p)
{
  Pix q = Pix(ch-><T>IChunk::succ((<T>*) p));
  p = (q == 0)? Pix(dosucc((<T>*)p)) : q;
}

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

#endif