Personal tools
You are here: Home Projects C++ Cfront releases Release 3.0.3 source incl-master const-headers Block.h
Document Actions

Block.h

by Michael L Powell last modified 2007-01-26 03:20

Click here to get the file

Size 1.9 kB - File type text/plain

File contents

/*ident	"@(#)Block:incl/Block.h	3.1" */
/******************************************************************************
*
* C++ Standard Components, Release 3.0.
*
* Copyright (c) 1991, 1992 AT&T and Unix System Laboratories, Inc.
* Copyright (c) 1988, 1989, 1990 AT&T.  All Rights Reserved.
*
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T and Unix System
* Laboratories, Inc.  The copyright notice above does not evidence
* any actual or intended publication of such source code.
*
******************************************************************************/

#ifndef BLOCK_H
#define BLOCK_H
#ifdef __GNUG__
#pragma interface
#endif

#include <new.h>

class ostream;

template <class T> class Block {
	void dummy_fcn();

public:
	Block() : n(0), p(0) { if (n != 0) dummy_fcn(); }
	Block(unsigned k) : n(0), p(0) { if (n != 0) dummy_fcn(); size(k); }
	Block(const Block<T>& b) { copy(b); }
	~Block();

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

	unsigned size() const { return n; }
	unsigned size(unsigned);

	operator T*() { return p; }
	operator const T*() const { return p; }

	T* end() { return p + n; }
	const T* end() const { return p + n; }

	T& operator[](int i) { return p[i]; }
	const T& operator[](int i) const { return p[i]; }
	T& operator[](unsigned i) { return p[i]; }
	const T& operator[](unsigned i) const { return p[i]; }

	int reserve(unsigned k) { return k<n || grow(k); }
	void swap(Block<T>& b);

#if defined(__SUNPRO_CC) || defined(__GNUG__)
	friend ostream& operator<<(ostream& os, const Block<T>& b);
#else
	template <class Type>
	friend ostream& operator<<(ostream& os, const Block<Type>& b);
#endif

private:
	T* p;
	unsigned n;

	void move(T*, unsigned);
	void transfer(T*, unsigned);
	void clear(T*, unsigned);
	void copy(const Block<T>&);
	unsigned grow(unsigned);
	static T* default_value();
};

#if (defined(__edg_att_40) || defined(__GNUG__)) && !defined(__IMPLICIT_INCLUDE)
#include <Block.c>
#endif
#endif
« July 2014 »
Su Mo Tu We Th Fr Sa
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
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: