dslinux/user/pixil/packages/dvdview/dvdview/libvideogfx/libvideogfx/containers Makefile.am Makefile.in array.cc array.hh array2.cc array2.hh heap.cc heap.hh queue.cc queue.hh

amadeus dslinux_amadeus at user.in-berlin.de
Tue Oct 3 13:25:37 CEST 2006


Update of /cvsroot/dslinux/dslinux/user/pixil/packages/dvdview/dvdview/libvideogfx/libvideogfx/containers
In directory antilope:/tmp/cvs-serv11916/packages/dvdview/dvdview/libvideogfx/libvideogfx/containers

Added Files:
	Makefile.am Makefile.in array.cc array.hh array2.cc array2.hh 
	heap.cc heap.hh queue.cc queue.hh 
Log Message:
adding pristine copy of pixil to HEAD so I can branch from it

--- NEW FILE: queue.hh ---
/********************************************************************************
  utility/queue.hh

  purpose:
    Queue container class template.

  notes:

  to do:

  author(s):
   - Dirk Farin, farin at ti.uni-mannheim.de

  modifications:
   29/Sep/1999 - Dirk Farin
     - integrated into libvideogfx CVS
   20/Nov/1998 - Dirk Farin
     - new method: AskAndRemoveHead()
 ********************************************************************************
    Copyright (C) 1999  Dirk Farin

    This program is distributed under GNU Public License (GPL) as
    outlined in the COPYING file that comes with the source distribution.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ********************************************************************************/

#ifndef LIBVIDEOGFX_UTILITY_QUEUE_HH
#define LIBVIDEOGFX_UTILITY_QUEUE_HH

#include "libvideogfx/types.hh"
#include <assert.h>

template <class T> class Queue
{
public:
   Queue();
  ~Queue();

  void Append(const T&);
  void AppendAtHead(const T&);
  T&   AskHead() const { assert(!IsEmpty()); assert(d_first<d_size); return d_queue[d_first]; }
  T&   AskTail() const;
  T&   AskFromHead(uint32 idx) const;  // 0 is first one, 1 is second one
  T&   AskFromTail(uint32 idx) const;  // 0 is last one,  1 is last but one
  void RemoveHead();
  void RemoveFromHead(uint32 idx);
  T&   AskAndRemoveHead() { T& x=AskHead(); RemoveHead(); return x; }

  bool   IsEmpty() const { return d_entries==0; }
  uint32 Length()  const { return d_entries;    }

private:
  T*  d_queue;
  int d_size;

  int d_first;
  int d_entries;

  void Enlarge();
};

#endif

--- NEW FILE: array2.hh ---
/********************************************************************************
  libvideogfx/containers/array2.hh

  purpose:
    Simple 2dim array class template.

  notes:

  to do:

  author(s):
   - Dirk Farin, farin at ti.uni-mannheim.de

  modifications:
   30/Sep/1999 - Dirk Farin
     - integrated from old DVDview into ULib
 ********************************************************************************
    Copyright (C) 1999  Dirk Farin

    This program is distributed under GNU Public License (GPL) as
    outlined in the COPYING file that comes with the source distribution.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ********************************************************************************/

#ifndef LIBVIDEOGFX_CONTAINERS_ARRAY2_HH
#define LIBVIDEOGFX_CONTAINERS_ARRAY2_HH

#include "libvideogfx/types.hh"


template <class T> class Array2
{
public:
  Array2();
  Array2(int width,int height);
  ~Array2();

  void Create(int width,int height);

  bool IsInitialized() const { return d_array != NULL; }

        T& Ask      (int y,int x)       { return d_array[y][x]; }
  const T& Ask_const(int y,int x) const { return d_array[y][x]; }

  int AskWidth()  const { return d_width;  }
  int AskHeight() const { return d_height; }

private:
  int   d_width,d_height;
  T**   d_array;
};

#endif

--- NEW FILE: array.hh ---
/********************************************************************************
  libvideogfx/containers/array.hh

  purpose:
    Simple 1dim array class template.

  notes:

  to do:

  author(s):
   - Dirk Farin, farin at ti.uni-mannheim.de

  modifications:
   19/Sep/2000 - Dirk Farin
   - New method CreateRange()
   30/Jun/2000 - Dirk Farin
   - first implementation
 ********************************************************************************
    Copyright (C) 1999  Dirk Farin

    This program is distributed under GNU Public License (GPL) as
    outlined in the COPYING file that comes with the source distribution.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ********************************************************************************/

#ifndef LIBVIDEOGFX_CONTAINERS_ARRAY_HH
#define LIBVIDEOGFX_CONTAINERS_ARRAY_HH

#include "libvideogfx/types.hh"


template <class T> class Array
{
public:
  Array();
  Array(const Array<T>&);
  Array(int size,int base=0);
  ~Array();

  void Create(int size,int base=0);
  void CreateRange(int first,int last) { Create(last-first+1,first); }
  void Destroy();

  bool IsInitialized() const { return d_array != NULL; }

        T* Data()             { return &d_array[d_baseoffset]; }
  const T* Data_const() const { return &d_array[d_baseoffset]; }

  int AskBase() const { return -d_baseoffset;  }
  int AskSize() const { return d_size; }
  int AskStartIdx() const { return AskBase(); }
  int AskEndIdx() const { return AskSize()+AskBase()-1; }

  const Array& operator=(const Array<T>&);

private:
  int   d_baseoffset,d_size;
  T*    d_array;
};

#endif

--- NEW FILE: array2.cc ---
/********************************************************************************
    Copyright (C) 1999  Dirk Farin

    This program is distributed under GNU Public License (GPL) as
    outlined in the COPYING file that comes with the source distribution.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ********************************************************************************/

#include "libvideogfx/containers/array2.hh"


template <class T> Array2<T>::Array2()
{
  d_width = d_height = 0;
  d_array = 0;
}


template <class T> Array2<T>::Array2(int width,int height)
{
  Create(width,height);
}


template <class T> void Array2<T>::Create(int width,int height)
{
  if (d_array)
    {
      if (d_width == width && d_height == height)
	return;

      delete[] d_array[0];
      delete[] d_array;
    }

  d_width  = width;
  d_height = height; 

  T* bitmap = new T[d_width * d_height];
  d_array   = new T* [d_height];

  {for (int y=0;y<d_height;y++)
    d_array[y]= &bitmap[y*d_width];}
}


template <class T> Array2<T>::~Array2()
{
  if (d_array)
    {
      delete[] d_array[0];
      delete[] d_array;
    }
}


--- NEW FILE: heap.cc ---
/********************************************************************************
    Copyright (C) 1999  Dirk Farin

    This program is distributed under GNU Public License (GPL) as
    outlined in the COPYING file that comes with the source distribution.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ********************************************************************************/

#include "config.h"

#include <assert.h>

#include "heap.hh"


#define INITIAL_SIZE 50

template <class T> Heap<T>::Heap()
  : d_heap(NULL), d_size(0), d_entries(0)
{
}

template <class T> Heap<T>::~Heap()
{
  if (d_heap) delete[] d_heap;
}

template <class T> void Heap<T>::Insert(const T& e)
{
  // If heap is full, allocate a bigger one and copy the old one into it.

  if (d_entries==d_size)
    {
      int newsize = max(max(d_size*2,d_size+10),INITIAL_SIZE);
      assert(newsize>d_size);

      T* newheap = new T[newsize+1]; // Create array for new heap including an extra dummy element [0].
      for (uint32 i=1;i<=d_entries;i++)
	newheap[i] = d_heap[i];

      if (d_heap) delete[] d_heap;
      d_heap = newheap;
      d_size = newsize;
    }

  d_entries++;
  d_heap[d_entries] = e;

  UpHeap(d_entries);
}

template <class T> void Heap<T>::UpHeap(int i)
{
  while (i>1 && d_heap[i/2].AskValue() > d_heap[i].AskValue())
    {
      swap(d_heap[i],d_heap[i/2]);
      i /= 2;
    }
}

template <class T> void Heap<T>::RemoveTop()
{
  d_heap[1] = d_heap[d_entries];
  d_entries--;
  DownHeap(1);
}

template <class T> void Heap<T>::DownHeap(int i)
{
again1:

  // Element ist am unteren Rand.
  if (i*2 > d_entries)
    return;

  if (i*2==d_entries ||
      d_heap[i*2].AskValue() < d_heap[i*2+1].AskValue())
    {
      if (d_heap[i].AskValue() > d_heap[i*2].AskValue())
        {
          swap(d_heap[i],d_heap[i*2]);
          i=i*2;
          goto again1;
        }
    }
  else
    {
      if (d_heap[i].AskValue() > d_heap[i*2+1].AskValue())
        {
          swap(d_heap[i],d_heap[i*2+1]);
          i=i*2+1;
          goto again1;
        }
    }
}


--- NEW FILE: array.cc ---
/********************************************************************************
    Copyright (C) 1999  Dirk Farin

    This program is distributed under GNU Public License (GPL) as
    outlined in the COPYING file that comes with the source distribution.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ********************************************************************************/

#include "array.hh"


template <class T> Array<T>::Array()
  : d_baseoffset(0),d_size(0), d_array(NULL)
{
}


template <class T> Array<T>::Array(int size,int base)
  : d_array(NULL)
{
  Create(size,base);
}


template <class T> Array<T>::Array(const Array<T>& a)
  : d_array(NULL)
{
  *this = a;
}


template <class T> void Array<T>::Create(int size,int base)
{
  if (d_array)
    {
      if (d_size == size)
	{
	  d_baseoffset = -base;
	  return;
	}

      delete[] d_array;
    }

  d_size       = size;
  d_baseoffset = -base;

  d_array   = new T[d_size];
}


template <class T> Array<T>::~Array()
{
  Destroy();
}


template <class T> void Array<T>::Destroy()
{
  if (d_array)
    {
      delete[] d_array;
    }

  d_array=NULL;
  d_baseoffset=0;
  d_size=0;
}


template <class T> const Array<T>& Array<T>::operator=(const Array<T>& a)
{
  Destroy();

  if (a.d_array)
    {
      Create(a.d_size, -a.d_baseoffset);

      for (int i=0;i<d_size;i++)
	d_array[i] = a.d_array[i];
    }

  return *this;
}

--- NEW FILE: Makefile.in ---
# Makefile.in generated automatically by automake 1.4 from Makefile.am

# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.


SHELL = @SHELL@

srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@

bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include

DESTDIR =

pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@

top_builddir = ../..

ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@

NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_alias = @build_alias@
build_triplet = @build@
host_alias = @host_alias@
host_triplet = @host@
target_alias = @target_alias@
target_triplet = @target@
AS = @AS@
CC = @CC@
CXX = @CXX@
DLLTOOL = @DLLTOOL@
LIBTOOL = @LIBTOOL@
LIBVIDEOGFX_BINARY_AGE = @LIBVIDEOGFX_BINARY_AGE@
LIBVIDEOGFX_INTERFACE_AGE = @LIBVIDEOGFX_INTERFACE_AGE@
LIBVIDEOGFX_MAJOR_VERSION = @LIBVIDEOGFX_MAJOR_VERSION@
LIBVIDEOGFX_MICRO_VERSION = @LIBVIDEOGFX_MICRO_VERSION@
LIBVIDEOGFX_MINOR_VERSION = @LIBVIDEOGFX_MINOR_VERSION@
LIBVIDEOGFX_VERSION = @LIBVIDEOGFX_VERSION@
LN_S = @LN_S@
LT_AGE = @LT_AGE@
LT_CURRENT = @LT_CURRENT@
LT_RELEASE = @LT_RELEASE@
LT_REVISION = @LT_REVISION@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
VERSION = @VERSION@
X_LDFLAGS = @X_LDFLAGS@

noinst_LTLIBRARIES = libvideogfx-containers.la

libvideogfx_containers_includedir = $(includedir)/libvideogfx/containers

# Header files for public installation (non-generated)
libvideogfx_containers_public_h_sources =  	heap.hh


# Header files that don't get installed
libvideogfx_containers_private_h_sources =  	array.hh		array.cc		array2.cc		array2.hh		queue.cc		queue.hh


# C sources to build the library from
libvideogfx_containers_c_sources =  	heap.cc


#
# setup sources and their dependancies
#
libvideogfx_containers_include_HEADERS = $(libvideogfx_containers_public_h_sources)
libvideogfx_containers_la_SOURCES = $(libvideogfx_containers_c_sources)
EXTRA_HEADERS =  
EXTRA_DIST =  $(libvideogfx_containers_private_h_sources)

INCLUDES =  	-I$(top_srcdir)

mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../../config.h
CONFIG_CLEAN_FILES = 
LTLIBRARIES =  $(noinst_LTLIBRARIES)


DEFS = @DEFS@ -I. -I$(srcdir) -I../..
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
X_CFLAGS = @X_CFLAGS@
X_LIBS = @X_LIBS@
X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_PRE_LIBS = @X_PRE_LIBS@
libvideogfx_containers_la_LDFLAGS = 
libvideogfx_containers_la_LIBADD = 
libvideogfx_containers_la_OBJECTS =  heap.lo
CXXFLAGS = @CXXFLAGS@
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
HEADERS =  $(libvideogfx_containers_include_HEADERS)

DIST_COMMON =  Makefile.am Makefile.in


DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)

TAR = gtar
GZIP_ENV = --best
DEP_FILES =  .deps/heap.P
SOURCES = $(libvideogfx_containers_la_SOURCES)
OBJECTS = $(libvideogfx_containers_la_OBJECTS)

all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .cc .lo .o .s
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
	cd $(top_srcdir) && $(AUTOMAKE) --gnu libvideogfx/containers/Makefile

Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status $(BUILT_SOURCES)
	cd $(top_builddir) \
	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status


mostlyclean-noinstLTLIBRARIES:

clean-noinstLTLIBRARIES:
	-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)

distclean-noinstLTLIBRARIES:

maintainer-clean-noinstLTLIBRARIES:

.s.o:
	$(COMPILE) -c $<

.S.o:
	$(COMPILE) -c $<

mostlyclean-compile:
	-rm -f *.o core *.core

clean-compile:

distclean-compile:
	-rm -f *.tab.c

maintainer-clean-compile:

.s.lo:
	$(LIBTOOL) --mode=compile $(COMPILE) -c $<

.S.lo:
	$(LIBTOOL) --mode=compile $(COMPILE) -c $<

mostlyclean-libtool:
	-rm -f *.lo

clean-libtool:
	-rm -rf .libs _libs

distclean-libtool:

maintainer-clean-libtool:

libvideogfx-containers.la: $(libvideogfx_containers_la_OBJECTS) $(libvideogfx_containers_la_DEPENDENCIES)
	$(CXXLINK)  $(libvideogfx_containers_la_LDFLAGS) $(libvideogfx_containers_la_OBJECTS) $(libvideogfx_containers_la_LIBADD) $(LIBS)
.cc.o:
	$(CXXCOMPILE) -c $<
.cc.lo:
	$(LTCXXCOMPILE) -c $<

install-libvideogfx_containers_includeHEADERS: $(libvideogfx_containers_include_HEADERS)
	@$(NORMAL_INSTALL)
	$(mkinstalldirs) $(DESTDIR)$(libvideogfx_containers_includedir)
	@list='$(libvideogfx_containers_include_HEADERS)'; for p in $$list; do \
	  if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \
	  echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(libvideogfx_containers_includedir)/$$p"; \
	  $(INSTALL_DATA) $$d$$p $(DESTDIR)$(libvideogfx_containers_includedir)/$$p; \
	done

uninstall-libvideogfx_containers_includeHEADERS:
	@$(NORMAL_UNINSTALL)
	list='$(libvideogfx_containers_include_HEADERS)'; for p in $$list; do \
	  rm -f $(DESTDIR)$(libvideogfx_containers_includedir)/$$p; \
	done

tags: TAGS

ID: $(HEADERS) $(SOURCES) $(LISP)
	list='$(SOURCES) $(HEADERS)'; \
	unique=`for i in $$list; do echo $$i; done | \
	  awk '    { files[$$0] = 1; } \
	       END { for (i in files) print i; }'`; \
	here=`pwd` && cd $(srcdir) \
	  && mkid -f$$here/ID $$unique $(LISP)

TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) $(LISP)
	tags=; \
	here=`pwd`; \
	list='$(SOURCES) $(HEADERS)'; \
	unique=`for i in $$list; do echo $$i; done | \
	  awk '    { files[$$0] = 1; } \
	       END { for (i in files) print i; }'`; \
	test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
	  || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags  $$unique $(LISP) -o $$here/TAGS)

mostlyclean-tags:

clean-tags:

distclean-tags:
	-rm -f TAGS ID

maintainer-clean-tags:

distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)

subdir = libvideogfx/containers

distdir: $(DISTFILES)
	here=`cd $(top_builddir) && pwd`; \
	top_distdir=`cd $(top_distdir) && pwd`; \
	distdir=`cd $(distdir) && pwd`; \
	cd $(top_srcdir) \
	  && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu libvideogfx/containers/Makefile
	@for file in $(DISTFILES); do \
	  d=$(srcdir); \
	  if test -d $$d/$$file; then \
	    cp -pr $$d/$$file $(distdir)/$$file; \
	  else \
	    test -f $(distdir)/$$file \
	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
	    || cp -p $$d/$$file $(distdir)/$$file || :; \
	  fi; \
	done

DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)

-include $(DEP_FILES)

mostlyclean-depend:

clean-depend:

distclean-depend:
	-rm -rf .deps

maintainer-clean-depend:

%.o: %.c
	@echo '$(COMPILE) -c $<'; \
	$(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
	@-cp .deps/$(*F).pp .deps/$(*F).P; \
	tr ' ' '\012' < .deps/$(*F).pp \
	  | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
	    >> .deps/$(*F).P; \
	rm .deps/$(*F).pp

%.lo: %.c
	@echo '$(LTCOMPILE) -c $<'; \
	$(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
	@-sed -e 's/^\([^:]*\)\.o[ 	]*:/\1.lo \1.o :/' \
	  < .deps/$(*F).pp > .deps/$(*F).P; \
	tr ' ' '\012' < .deps/$(*F).pp \
	  | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
	    >> .deps/$(*F).P; \
	rm -f .deps/$(*F).pp

%.o: %.cc
	@echo '$(CXXCOMPILE) -c $<'; \
	$(CXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
	@-cp .deps/$(*F).pp .deps/$(*F).P; \
	tr ' ' '\012' < .deps/$(*F).pp \
	  | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
	    >> .deps/$(*F).P; \
	rm .deps/$(*F).pp

%.lo: %.cc
	@echo '$(LTCXXCOMPILE) -c $<'; \
	$(LTCXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
	@-sed -e 's/^\([^:]*\)\.o[ 	]*:/\1.lo \1.o :/' \
	  < .deps/$(*F).pp > .deps/$(*F).P; \
	tr ' ' '\012' < .deps/$(*F).pp \
	  | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
	    >> .deps/$(*F).P; \
	rm -f .deps/$(*F).pp
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am:
install-exec: install-exec-am

install-data-am: install-libvideogfx_containers_includeHEADERS
install-data: install-data-am

install-am: all-am
	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am: uninstall-libvideogfx_containers_includeHEADERS
uninstall: uninstall-am
all-am: Makefile $(LTLIBRARIES) $(HEADERS)
all-redirect: all-am
install-strip:
	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
	$(mkinstalldirs)  $(DESTDIR)$(libvideogfx_containers_includedir)


mostlyclean-generic:

clean-generic:

distclean-generic:
	-rm -f Makefile $(CONFIG_CLEAN_FILES)
	-rm -f config.cache config.log stamp-h stamp-h[0-9]*

maintainer-clean-generic:
mostlyclean-am:  mostlyclean-noinstLTLIBRARIES mostlyclean-compile \
		mostlyclean-libtool mostlyclean-tags mostlyclean-depend \
		mostlyclean-generic

mostlyclean: mostlyclean-am

clean-am:  clean-noinstLTLIBRARIES clean-compile clean-libtool \
		clean-tags clean-depend clean-generic mostlyclean-am

clean: clean-am

distclean-am:  distclean-noinstLTLIBRARIES distclean-compile \
		distclean-libtool distclean-tags distclean-depend \
		distclean-generic clean-am
	-rm -f libtool

distclean: distclean-am

maintainer-clean-am:  maintainer-clean-noinstLTLIBRARIES \
		maintainer-clean-compile maintainer-clean-libtool \
		maintainer-clean-tags maintainer-clean-depend \
		maintainer-clean-generic distclean-am
	@echo "This command is intended for maintainers to use;"
	@echo "it deletes files that may require special tools to rebuild."

maintainer-clean: maintainer-clean-am

.PHONY: mostlyclean-noinstLTLIBRARIES distclean-noinstLTLIBRARIES \
clean-noinstLTLIBRARIES maintainer-clean-noinstLTLIBRARIES \
mostlyclean-compile distclean-compile clean-compile \
maintainer-clean-compile mostlyclean-libtool distclean-libtool \
clean-libtool maintainer-clean-libtool \
uninstall-libvideogfx_containers_includeHEADERS \
install-libvideogfx_containers_includeHEADERS tags mostlyclean-tags \
distclean-tags clean-tags maintainer-clean-tags distdir \
mostlyclean-depend distclean-depend clean-depend \
maintainer-clean-depend info-am info dvi-am dvi check check-am \
installcheck-am installcheck install-exec-am install-exec \
install-data-am install-data install-am install uninstall-am uninstall \
all-redirect all-am all installdirs mostlyclean-generic \
distclean-generic clean-generic maintainer-clean-generic clean \
mostlyclean distclean maintainer-clean


.PHONY: files

files:
	@files=`ls $(DISTFILES) 2> /dev/null`; for p in $$files; do \
	  echo $$p; \
	done

# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

--- NEW FILE: queue.cc ---
/********************************************************************************
    Copyright (C) 1999  Dirk Farin

    This program is distributed under GNU Public License (GPL) as
    outlined in the COPYING file that comes with the source distribution.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ********************************************************************************/

#include "libvideogfx/containers/queue.hh"
#include <assert.h>


#define INITIAL_SIZE 50

template <class T> Queue<T>::Queue()
  : d_queue(NULL), d_size(0), d_entries(0)
{
}

template <class T> Queue<T>::~Queue()
{
  if (d_queue) delete[] d_queue;
}

template <class T> void Queue<T>::Append(const T& e)
{
  // If queue is full, allocate a bigger one and copy the old one into it.

  if (d_entries==d_size)
    {
      Enlarge();
    }

  d_queue[ (d_first+d_entries)%d_size ] = e;
  d_entries++;
}

template <class T> void Queue<T>::AppendAtHead(const T& e)
{
  // If queue is full, allocate a bigger one and copy the old one into it.

  if (d_entries==d_size)
    {
      Enlarge();
    }

  d_first = (d_first-1+d_size)%d_size;
  d_queue[d_first] = e;
  d_entries++;
}

template <class T> void Queue<T>::Enlarge()
{
  int newsize = max(max(d_size*2,d_size+10),INITIAL_SIZE);
  assert(newsize>d_size);

  T* newqueue = new T[newsize];
  for (uint32 i=0;i<d_entries;i++)
    newqueue[i] = d_queue[(i+d_first)%d_size];

  if (d_queue) delete[] d_queue;
  d_queue = newqueue;
  d_size  = newsize;
  d_first = 0;
}

template <class T> T& Queue<T>::AskTail() const
{
  assert(!IsEmpty());
  return d_queue[(d_first+d_entries-1)%d_size];
}

template <class T> T& Queue<T>::AskFromHead(uint32 idx) const
{
  assert(!IsEmpty());
  assert(idx<d_entries);
  return d_queue[(d_first+idx)%d_size];
}

template <class T> T& Queue<T>::AskFromTail(uint32 idx) const
{
  assert(!IsEmpty());
  assert(idx<d_entries);
  return d_queue[(d_first+d_entries-1-idx)%d_size];
}

template <class T> void Queue<T>::RemoveHead()
{
  assert(!IsEmpty());
  d_first++; d_first %= d_size;
  d_entries--;
}

template <class T> void Queue<T>::RemoveFromHead(uint32 idx)
{
  assert(!IsEmpty());
  assert(idx<d_entries);

  for (uint32 i=0;i<d_entries-idx-1;i++)
    d_queue[(d_first+idx+i)%d_size] = d_queue[(d_first+idx+i+1)%d_size];

  d_entries--;
}

--- NEW FILE: Makefile.am ---
## Makefile.am for libvideogfx/libvideogfx/containers

noinst_LTLIBRARIES = libvideogfx-containers.la

libvideogfx_containers_includedir = $(includedir)/libvideogfx/containers

# Header files for public installation (non-generated)
libvideogfx_containers_public_h_sources = \
	heap.hh

# Header files that don't get installed
libvideogfx_containers_private_h_sources = \
	array.hh	\
	array.cc	\
	array2.cc	\
	array2.hh	\
	queue.cc	\
	queue.hh

# C sources to build the library from
libvideogfx_containers_c_sources = \
	heap.cc

#
# setup sources and their dependancies
#
libvideogfx_containers_include_HEADERS = $(libvideogfx_containers_public_h_sources)
libvideogfx_containers_la_SOURCES = $(libvideogfx_containers_c_sources)
EXTRA_HEADERS +=
EXTRA_DIST += $(libvideogfx_containers_private_h_sources)

INCLUDES = \
	-I$(top_srcdir)

.PHONY: files

files:
	@files=`ls $(DISTFILES) 2> /dev/null`; for p in $$files; do \
	  echo $$p; \
	done

--- NEW FILE: heap.hh ---
/********************************************************************************
  utility/heap.hh

  purpose:
    Heap container class template.

  notes:

  to do:

  author(s):
   - Dirk Farin, farin at ti.uni-mannheim.de

  modifications:
   05/Jan/2000 - Dirk Farin
     - first revision
 ********************************************************************************
    Copyright (C) 1999  Dirk Farin

    This program is distributed under GNU Public License (GPL) as
    outlined in the COPYING file that comes with the source distribution.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ********************************************************************************/

#ifndef LIBVIDEOGFX_UTILITY_HEAP_HH
#define LIBVIDEOGFX_UTILITY_HEAP_HH

#include <assert.h>

#include "libvideogfx/types.hh"


class HeapElement
{
public:
  virtual ~HeapElement() { }

  virtual int AskValue() const = 0;
};

template <class T> class Heap
{
public:
   Heap();
  ~Heap();

  void Insert(const T&);
  T&   AskTop() const { assert(d_entries>0); return d_heap[1]; }
  void RemoveTop(); // Remove minimum element.

  bool   IsEmpty() const { return d_entries==0; }
  uint32 Length()  const { return d_entries;    }

private:
  T*  d_heap;
  int d_size; // Size of heap excluding the first (dummy) element

  int d_entries;

  void UpHeap(int i);
  void DownHeap(int i);
};

#endif




More information about the dslinux-commit mailing list