Upload missing files.

This commit is contained in:
Night Owl 2017-03-16 02:15:18 +05:00
parent 13a9a954d9
commit d9d2db6538
21 changed files with 5296 additions and 0 deletions

142
dlls/aghl/multi_gamerules.h Normal file
View File

@ -0,0 +1,142 @@
/***
*
* Copyright (c) 1999, 2000 Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
//
// multi_gamerules.h
//
//=========================================================
// CHalfLifeMultiplay - rules for the basic half life multiplayer
// competition
//=========================================================
//++ BulliT
#if !defined(_MULTIPLAY_H_)
#define _MULTIPLAY_H_
#include "aggamerules.h"
//-- Martin Webrant
//=========================================================
// CHalfLifeMultiplay - rules for the basic half life multiplayer
// competition
//=========================================================
//++ BulliT
class CHalfLifeMultiplay : public AgGameRules
//class CHalfLifeMultiplay : public CGameRules
//-- Martin Webrant
{
public:
CHalfLifeMultiplay();
// GR_Think
virtual void Think( void );
virtual void RefreshSkillData( void );
virtual BOOL IsAllowedToSpawn( CBaseEntity *pEntity );
virtual BOOL FAllowFlashlight( void );
virtual BOOL FShouldSwitchWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon );
virtual BOOL GetNextBestWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pCurrentWeapon );
// Functions to verify the single/multiplayer status of a game
virtual BOOL IsMultiplayer( void );
virtual BOOL IsDeathmatch( void );
virtual BOOL IsCoOp( void );
// Client connection/disconnection
// If ClientConnected returns FALSE, the connection is rejected and the user is provided the reason specified in
// svRejectReason
// Only the client's name and remote address are provided to the dll for verification.
virtual BOOL ClientConnected( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] );
virtual void InitHUD( CBasePlayer *pl ); // the client dll is ready for updating
virtual void ClientDisconnected( edict_t *pClient );
virtual void UpdateGameMode( CBasePlayer *pPlayer ); // the client needs to be informed of the current game mode
// Client damage rules
virtual float FlPlayerFallDamage( CBasePlayer *pPlayer );
virtual BOOL FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity *pAttacker );
// Client spawn/respawn control
virtual void PlayerSpawn( CBasePlayer *pPlayer );
virtual void PlayerThink( CBasePlayer *pPlayer );
virtual BOOL FPlayerCanRespawn( CBasePlayer *pPlayer );
virtual float FlPlayerSpawnTime( CBasePlayer *pPlayer );
virtual edict_t *GetPlayerSpawnSpot( CBasePlayer *pPlayer );
virtual BOOL AllowAutoTargetCrosshair( void );
virtual BOOL ClientCommand( CBasePlayer *pPlayer, const char *pcmd );
// Client kills/scoring
virtual int IPointsForKill( CBasePlayer *pAttacker, CBasePlayer *pKilled );
virtual void PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor );
virtual void DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pInflictor );
// Weapon retrieval
virtual void PlayerGotWeapon( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon );
virtual BOOL CanHavePlayerItem( CBasePlayer *pPlayer, CBasePlayerItem *pWeapon );// The player is touching an CBasePlayerItem, do I give it to him?
// Weapon spawn/respawn control
virtual int WeaponShouldRespawn( CBasePlayerItem *pWeapon );
virtual float FlWeaponRespawnTime( CBasePlayerItem *pWeapon );
virtual float FlWeaponTryRespawn( CBasePlayerItem *pWeapon );
virtual Vector VecWeaponRespawnSpot( CBasePlayerItem *pWeapon );
// Item retrieval
virtual BOOL CanHaveItem( CBasePlayer *pPlayer, CItem *pItem );
virtual void PlayerGotItem( CBasePlayer *pPlayer, CItem *pItem );
// Item spawn/respawn control
virtual int ItemShouldRespawn( CItem *pItem );
virtual float FlItemRespawnTime( CItem *pItem );
virtual Vector VecItemRespawnSpot( CItem *pItem );
// Ammo retrieval
virtual void PlayerGotAmmo( CBasePlayer *pPlayer, char *szName, int iCount );
// Ammo spawn/respawn control
virtual int AmmoShouldRespawn( CBasePlayerAmmo *pAmmo );
virtual float FlAmmoRespawnTime( CBasePlayerAmmo *pAmmo );
virtual Vector VecAmmoRespawnSpot( CBasePlayerAmmo *pAmmo );
// Healthcharger respawn control
virtual float FlHealthChargerRechargeTime( void );
virtual float FlHEVChargerRechargeTime( void );
// What happens to a dead player's weapons
virtual int DeadPlayerWeapons( CBasePlayer *pPlayer );
// What happens to a dead player's ammo
virtual int DeadPlayerAmmo( CBasePlayer *pPlayer );
// Teamplay stuff
virtual const char *GetTeamID( CBaseEntity *pEntity ) {return "";}
virtual int PlayerRelationship( CBaseEntity *pPlayer, CBaseEntity *pTarget );
virtual BOOL PlayTextureSounds( void ) { return FALSE; }
virtual BOOL PlayFootstepSounds( CBasePlayer *pl, float fvol );
// Monsters
virtual BOOL FAllowMonsters( void );
// Immediately end a multiplayer game
virtual void EndMultiplayerGame( void ) { GoToIntermission(); }
protected:
virtual void ChangeLevel( void );
virtual void GoToIntermission( void );
float m_flIntermissionEndTime;
BOOL m_iEndIntermissionButtonHit;
void SendMOTDToClient( edict_t *client );
};
#endif //_MULTIPLAY_H_

95
ministl/algo.h Normal file
View File

@ -0,0 +1,95 @@
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*/
#ifndef ALGO_H
#define ALGO_H
#include <stdlib.h>
#ifndef __GNUG__
#include <ministl/bool.h>
#endif
#include <ministl/pair>
template <class InputIterator, class Function>
Function for_each(InputIterator first, InputIterator last, Function f) {
while (first != last) f(*first++);
return f;
}
template <class InputIterator, class T>
InputIterator find(InputIterator first, InputIterator last, const T& value) {
while (first != last && *first != value) ++first;
return first;
}
template <class InputIterator, class Predicate>
InputIterator find_if(InputIterator first, InputIterator last,
Predicate pred) {
while (first != last && !pred(*first)) ++first;
return first;
}
template <class ForwardIterator>
ForwardIterator adjacent_find(ForwardIterator first, ForwardIterator last) {
if (first == last) return last;
ForwardIterator next = first;
while(++next != last) {
if (*first == *next) return first;
first = next;
}
return last;
}
template <class ForwardIterator, class BinaryPredicate>
ForwardIterator adjacent_find(ForwardIterator first, ForwardIterator last,
BinaryPredicate binary_pred) {
if (first == last) return last;
ForwardIterator next = first;
while(++next != last) {
if (binary_pred(*first, *next)) return first;
first = next;
}
return last;
}
template <class InputIterator, class T, class Size>
void count(InputIterator first, InputIterator last, const T& value,
Size& n) {
while (first != last)
if (*first++ == value) ++n;
}
template <class InputIterator, class Predicate, class Size>
void count_if(InputIterator first, InputIterator last, Predicate pred,
Size& n) {
while (first != last)
if (pred(*first++)) ++n;
}
template<class _II, class _OI, class _Uop> inline
_OI transform(_II _F, _II _L, _OI _X, _Uop _U)
{for (; _F != _L; ++_F, ++_X)
*_X = _U(*_F);
return (_X); }
// TEMPLATE FUNCTION transform WITH BINARY OP
template<class _II1, class _II2, class _OI, class _Bop> inline
_OI transform(_II1 _F1, _II1 _L1, _II2 _F2, _OI _X, _Bop _B)
{for (; _F1 != _L1; ++_F1, ++_F2, ++_X)
*_X = _B(*_F1, *_F2);
return (_X); }
// TEMPLATE FUNCTION replace
#endif

23
ministl/algorithm Normal file
View File

@ -0,0 +1,23 @@
/*
* MICO --- a free CORBA implementation
* Copyright (C) 1997-98 Kay Roemer & Arno Puder
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Send comments and/or bug reports to:
* mico@informatik.uni-frankfurt.de
*/
#include <ministl/algo.h>

51
ministl/bool.h Normal file
View File

@ -0,0 +1,51 @@
// Defining TRUE and FALSE is usually a Bad Idea,
// because you will probably be inconsistent with anyone
// else who had the same clever idea.
// Therefore: DON'T USE THIS FILE.
#ifndef _bool_h
#define _bool_h 1
// make sure a config.h has been included before
#if defined(__GNUG__) || defined(HAVE_BOOL_TYPE)
#undef TRUE
#undef FALSE
#define TRUE true
#define FALSE false
#else
class bool {
int rep;
public:
bool ()
: rep(0)
{}
bool (int i)
: rep(!!i)
{}
bool (const bool &b)
: rep(b.rep)
{}
bool &operator= (const bool b)
{ rep = b.rep; return *this; }
bool &operator= (int i)
{ rep = !!i; return *this; }
operator int ()
{ return rep; }
operator int() const
{ return rep; }
};
#undef true
#undef false
#define true (bool(1))
#define false (bool(0))
#endif
#endif

2611
ministl/bstring.h Normal file

File diff suppressed because it is too large Load Diff

83
ministl/defalloc.h Normal file
View File

@ -0,0 +1,83 @@
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*/
#ifndef DEFALLOC_H
#define DEFALLOC_H
template <class T>
inline void destroy(T* pointer)
{
pointer->~T();
}
static inline void destroy(char*) {}
static inline void destroy(unsigned char*) {}
static inline void destroy(short*) {}
static inline void destroy(unsigned short*) {}
static inline void destroy(int*) {}
static inline void destroy(unsigned int*) {}
static inline void destroy(long*) {}
static inline void destroy(unsigned long*) {}
static inline void destroy(float*) {}
static inline void destroy(double*) {}
static inline void destroy(char**) {}
static inline void destroy(unsigned char**) {}
static inline void destroy(short**) {}
static inline void destroy(unsigned short**) {}
static inline void destroy(int**) {}
static inline void destroy(unsigned int**) {}
static inline void destroy(long**) {}
static inline void destroy(unsigned long**) {}
static inline void destroy(float**) {}
static inline void destroy(double**) {}
template <class T>
inline void destroy(T* beg, T* end)
{
for ( ; beg != end; ++beg)
beg->~T();
}
static inline void destroy(char*, char*) {}
static inline void destroy(unsigned char*, unsigned char*) {}
static inline void destroy(short*, short*) {}
static inline void destroy(unsigned short*, unsigned short*) {}
static inline void destroy(int*, int*) {}
static inline void destroy(unsigned int*, unsigned int*) {}
static inline void destroy(long*, long*) {}
static inline void destroy(unsigned long*, unsigned long*) {}
static inline void destroy(float*, float*) {}
static inline void destroy(double*, double*) {}
static inline void destroy(char**, char**) {}
static inline void destroy(unsigned char**, unsigned char**) {}
static inline void destroy(short**, short**) {}
static inline void destroy(unsigned short**, unsigned short**) {}
static inline void destroy(int**, int**) {}
static inline void destroy(unsigned int**, unsigned int**) {}
static inline void destroy(long**, long**) {}
static inline void destroy(unsigned long**, unsigned long**) {}
static inline void destroy(float**, float**) {}
static inline void destroy(double**, double**) {}
#if defined (__GNUG__)
static inline void *operator new(size_t, void *place) { return place; }
static inline void *operator new[](size_t, void *place) { return place; }
#else
#include <new.h>
#endif
#endif

23
ministl/function Normal file
View File

@ -0,0 +1,23 @@
/*
* MICO --- a free CORBA implementation
* Copyright (C) 1997-98 Kay Roemer & Arno Puder
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Send comments and/or bug reports to:
* mico@informatik.uni-frankfurt.de
*/
#include <ministl/function.h>

285
ministl/function.h Normal file
View File

@ -0,0 +1,285 @@
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*/
#ifndef FUNCTION_H
#define FUNCTION_H
#ifndef __GNUG__
#include <ministl/bool.h>
#endif
#if 0
template <class T1, class T2>
inline bool operator!=(const T1& x, const T2& y) {
return !(x == y);
}
#endif
template <class T1, class T2>
inline bool operator>(const T1& x, const T2& y) {
return y < x;
}
template <class T1, class T2>
inline bool operator<=(const T1& x, const T2& y) {
return !(y < x);
}
template <class T1, class T2>
inline bool operator>=(const T1& x, const T2& y) {
return !(x < y);
}
template <class Arg, class Result>
struct unary_function {
typedef Arg argument_type;
typedef Result result_type;
};
template <class Arg1, class Arg2, class Result>
struct binary_function {
typedef Arg1 first_argument_type;
typedef Arg2 second_argument_type;
typedef Result result_type;
};
template <class T>
struct plus : binary_function<T, T, T> {
T operator()(const T& x, const T& y) const { return x + y; }
};
template <class T>
struct minus : binary_function<T, T, T> {
T operator()(const T& x, const T& y) const { return x - y; }
};
template <class T>
struct multiplies : binary_function<T, T, T> {
T operator()(const T& x, const T& y) const { return x * y; }
};
template <class T>
struct divides : binary_function<T, T, T> {
T operator()(const T& x, const T& y) const { return x / y; }
};
template <class T>
#ifdef __GNU__
struct modulus {
typedef T first_argument_type;
typedef T second_argument_type;
typedef T result_type;
T operator()(const T& x, const T& y) const { return x % y; }
};
#else
struct modulus : binary_function<T, T, T> {
T operator()(const T& x, const T& y) const { return x % y; }
};
#endif
template <class T>
struct negate : unary_function<T, T> {
T operator()(const T& x) const { return -x; }
};
template <class T>
struct equal_to : binary_function<T, T, bool> {
bool operator()(const T& x, const T& y) const { return x == y; }
};
template <class T>
struct not_equal_to : binary_function<T, T, bool> {
bool operator()(const T& x, const T& y) const { return x != y; }
};
template <class T>
struct greater : binary_function<T, T, bool> {
bool operator()(const T& x, const T& y) const { return x > y; }
};
template <class T>
struct less : binary_function<T, T, bool> {
bool operator()(const T& x, const T& y) const { return x < y; }
};
template <class T>
struct greater_equal : binary_function<T, T, bool> {
bool operator()(const T& x, const T& y) const { return x >= y; }
};
template <class T>
struct less_equal : binary_function<T, T, bool> {
bool operator()(const T& x, const T& y) const { return x <= y; }
};
template <class T>
struct logical_and : binary_function<T, T, bool> {
bool operator()(const T& x, const T& y) const { return x && y; }
};
template <class T>
struct logical_or : binary_function<T, T, bool> {
bool operator()(const T& x, const T& y) const { return x || y; }
};
template <class T>
struct logical_not : unary_function<T, bool> {
bool operator()(const T& x) const { return !x; }
};
template <class Predicate>
class unary_negate : public unary_function<typename Predicate::argument_type, bool> {
protected:
Predicate pred;
public:
unary_negate(const Predicate& x) : pred(x) {}
bool operator()(const typename Predicate::argument_type& x) const
{ return !pred(x); }
};
template <class Predicate>
unary_negate<Predicate> not1(const Predicate& pred) {
return unary_negate<Predicate>(pred);
}
template <class Predicate>
class binary_negate
: public binary_function<typename Predicate::first_argument_type,
typename Predicate::second_argument_type, bool> {
protected:
Predicate pred;
public:
binary_negate(const Predicate& x) : pred(x) {}
bool operator()(const typename Predicate::first_argument_type& x,
const typename Predicate::second_argument_type& y) const {
return !pred(x, y);
}
};
template <class Predicate>
binary_negate<Predicate> not2(const Predicate& pred) {
return binary_negate<Predicate>(pred);
}
template <class Operation>
class binder1st : public unary_function<typename Operation::second_argument_type,
typename Operation::result_type> {
protected:
Operation op;
typename Operation::first_argument_type value;
public:
binder1st(const Operation& x, const typename Operation::first_argument_type& y)
: op(x), value(y) {}
typename Operation::result_type operator()(const typename Operation::argument_type& x) const {
return op(value, x);
}
};
template <class Operation, class T>
binder1st<Operation> bind1st(const Operation& op, const T& x) {
return binder1st<Operation>(op, Operation::first_argument_type(x));
}
template <class Operation>
class binder2nd : public unary_function<typename Operation::first_argument_type,
typename Operation::result_type> {
protected:
Operation op;
typename Operation::second_argument_type value;
public:
binder2nd(const Operation& x, const typename Operation::second_argument_type& y)
: op(x), value(y) {}
typename Operation::result_type operator()(const typename Operation::argument_type& x) const {
return op(x, value);
}
};
template <class Operation, class T>
binder2nd<Operation> bind2nd(const Operation& op, const T& x) {
return binder2nd<Operation>(op, Operation::second_argument_type(x));
}
template <class Operation1, class Operation2>
class unary_compose : public unary_function<typename Operation2::argument_type,
typename Operation1::result_type> {
protected:
Operation1 op1;
Operation2 op2;
public:
unary_compose(const Operation1& x, const Operation2& y) : op1(x), op2(y) {}
typename Operation1::result_type operator()(const typename Operation2::argument_type& x) const {
return op1(op2(x));
}
};
template <class Operation1, class Operation2>
unary_compose<Operation1, Operation2> compose1(const Operation1& op1,
const Operation2& op2) {
return unary_compose<Operation1, Operation2>(op1, op2);
}
template <class Operation1, class Operation2, class Operation3>
class binary_compose : public unary_function<typename Operation2::argument_type,
typename Operation1::result_type> {
protected:
Operation1 op1;
Operation2 op2;
Operation3 op3;
public:
binary_compose(const Operation1& x, const Operation2& y,
const Operation3& z) : op1(x), op2(y), op3(z) { }
typename Operation1::result_type operator()(const typename Operation2::argument_type& x) const {
return op1(op2(x), op3(x));
}
};
template <class Operation1, class Operation2, class Operation3>
binary_compose<Operation1, Operation2, Operation3>
compose2(const Operation1& op1, const Operation2& op2, const Operation3& op3) {
return binary_compose<Operation1, Operation2, Operation3>(op1, op2, op3);
}
template <class Arg, class Result>
class pointer_to_unary_function : public unary_function<Arg, Result> {
protected:
Result (*ptr)(Arg);
public:
pointer_to_unary_function() {}
pointer_to_unary_function(Result (*x)(Arg)) : ptr(x) {}
Result operator()(Arg x) const { return ptr(x); }
};
template <class Arg, class Result>
pointer_to_unary_function<Arg, Result> ptr_fun(Result (*x)(Arg)) {
return pointer_to_unary_function<Arg, Result>(x);
}
template <class Arg1, class Arg2, class Result>
class pointer_to_binary_function : public binary_function<Arg1, Arg2, Result> {
protected:
Result (*ptr)(Arg1, Arg2);
public:
pointer_to_binary_function() {}
pointer_to_binary_function(Result (*x)(Arg1, Arg2)) : ptr(x) {}
Result operator()(Arg1 x, Arg2 y) const { return ptr(x, y); }
};
template <class Arg1, class Arg2, class Result>
pointer_to_binary_function<Arg1, Arg2, Result>
ptr_fun(Result (*x)(Arg1, Arg2)) {
return pointer_to_binary_function<Arg1, Arg2, Result>(x);
}
#endif

23
ministl/list Normal file
View File

@ -0,0 +1,23 @@
/*
* MICO --- a free CORBA implementation
* Copyright (C) 1997-98 Kay Roemer & Arno Puder
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Send comments and/or bug reports to:
* mico@informatik.uni-frankfurt.de
*/
#include <ministl/list.h>

416
ministl/list.h Normal file
View File

@ -0,0 +1,416 @@
// -*- c++ -*-
/*
* MICO --- a free CORBA implementation
* Copyright (C) 1997-98 Kay Roemer & Arno Puder
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Send comments and/or bug reports to:
* mico@informatik.uni-frankfurt.de
*/
#ifndef __ministl_list_h__
#define __ministl_list_h__
#include <ministl/ministl.h>
#ifndef __GNUG__
#include <ministl/bool.h>
#endif
template<class T>
class listNode {
listNode<T> *_prev, *_next;
T _data;
public:
listNode (const T &data = T(), listNode<T> *next = 0,
listNode<T> *prev = 0)
: _prev (prev), _next (next), _data (data)
{
}
~listNode ()
{
ministl_assert (!_next && !_prev);
}
void remove ()
{
if (_prev)
_prev->_next = _next;
if (_next)
_next->_prev = _prev;
_next = _prev = 0;
}
void insert_after (listNode<T> *ln)
{
ministl_assert (ln);
_next = _prev = 0;
if (ln->_next)
ln->_next->_prev = this;
_next = ln->_next;
ln->_next = this;
_prev = ln;
}
void insert_before (listNode<T> *ln)
{
ministl_assert (ln);
_next = _prev = 0;
if (ln->_prev)
ln->_prev->_next = this;
_prev = ln->_prev;
ln->_prev = this;
_next = ln;
}
const T &data () const
{
return _data;
}
T &data ()
{
return _data;
}
listNode<T> *next ()
{
return _next;
}
listNode<T> *prev ()
{
return _prev;
}
};
template<class T> class list;
template<class T> class listConstIterator;
template<class T>
class listIterator {
friend class list<T>;
friend class listConstIterator<T>;
typedef listNode<T> node;
node *n;
listIterator (node *_n)
: n (_n)
{
}
public:
listIterator ()
: n (0)
{
}
bool operator== (const listIterator<T> &it) const
{
return it.n == n;
}
bool operator!= (const listIterator<T> &it) const
{
return !(it.n == n);
}
listIterator<T> operator++ ()
{
n = n->next();
ministl_assert (n);
return *this;
}
listIterator<T> operator++ (int)
{
listIterator<T> tmp = *this;
n = n->next();
ministl_assert (n);
return tmp;
}
listIterator<T> operator-- ()
{
n = n->prev();
ministl_assert (n);
return *this;
}
listIterator<T> operator-- (int)
{
listIterator<T> tmp = *this;
n = n->prev();
ministl_assert (n);
return tmp;
}
T &operator* ()
{
return n->data();
}
};
template<class T>
class listConstIterator {
friend class list<T>;
typedef listNode<T> node;
node *n;
listConstIterator (node *_n)
: n (_n)
{
}
public:
listConstIterator ()
: n (0)
{
}
listConstIterator (const listIterator<T> &i)
: n (i.n)
{
}
bool operator== (const listConstIterator<T> &it) const
{
return it.n == n;
}
bool operator!= (const listConstIterator<T> &it) const
{
return !(it.n == n);
}
listConstIterator<T> operator++ ()
{
n = n->next();
ministl_assert (n);
return *this;
}
listConstIterator<T> operator++ (int)
{
listConstIterator<T> tmp = *this;
n = n->next();
ministl_assert (n);
return tmp;
}
listConstIterator<T> operator-- ()
{
n = n->prev();
ministl_assert (n);
return *this;
}
listConstIterator<T> operator-- (int)
{
listConstIterator<T> tmp = *this;
n = n->prev();
ministl_assert (n);
return tmp;
}
const T &operator* () const
{
return n->data();
}
};
template<class T>
class list {
typedef listNode<T> node;
public:
typedef unsigned long size_type;
typedef listIterator<T> iterator;
typedef listConstIterator<T> const_iterator;
private:
node *_begin;
node *_end;
size_type _length;
public:
#if 0
void __check ()
{
node *n = _begin;
while (n->next())
n = n->next();
assert (n == _end);
}
#endif
iterator begin ()
{
return iterator (_begin);
}
const_iterator begin () const
{
return const_iterator (_begin);
}
iterator end ()
{
return iterator (_end);
}
const_iterator end () const
{
return const_iterator (_end);
}
list ()
: _length (0)
{
_begin = _end = new node ();
}
list (size_type n, const T &t = T())
: _length (0)
{
_begin = _end = new node ();
insert (begin(), n, t);
}
list (const T *first, const T *last)
: _length (0)
{
_begin = _end = new node ();
insert (begin(), first, last);
}
list (const_iterator first, const_iterator last)
: _length (0)
{
_begin = _end = new node ();
insert (begin(), first, last);
}
/*
typedef list<T> list_T;
list (const list_T &list)
: _length (0)
{
_begin = _end = new node ();
insert (begin(), list.begin(), list.end());
}
list<T> &operator= (const list<T> &list)
{
if (this != &list) {
erase (begin(), end());
insert (begin(), list.begin(), list.end());
}
return *this;
}
*/
~list ()
{
erase (begin(), end());
delete _end;
}
T &front ()
{
return _begin->data();
}
const T &front () const
{
return _begin->data();
}
T &back ()
{
ministl_assert (_end->prev());
return _end->prev()->data();
}
const T &back () const
{
ministl_assert (_end->prev());
return _end->prev()->data();
}
bool empty () const
{
return _length == 0;
}
void clear ()
{
erase (begin(), end());
}
size_type size () const
{
return _length;
}
void push_front (const T &t)
{
insert (begin(), t);
}
void pop_front ()
{
ministl_assert (size() > 0);
erase (begin());
}
void push_back (const T &t)
{
insert (end(), t);
}
void pop_back ()
{
ministl_assert (size() > 0);
erase (--end());
}
iterator insert (iterator pos, const T &t)
{
node *n = new node (t);
n->insert_before (pos.n);
if (pos.n == _begin)
_begin = n;
++_length;
return iterator (n);
}
void insert (iterator pos, size_type n, const T &t)
{
for (size_type i = 0; i < n; ++i)
insert (pos, t);
}
void insert (iterator pos, const T *first, const T *last)
{
for ( ; first != last; ++first)
insert (pos, *first);
}
void insert (iterator pos, const_iterator first, const_iterator last)
{
for ( ; first != last; ++first)
insert (pos, *first);
}
void erase (iterator pos)
{
if (pos != end()) {
ministl_assert (pos.n != _end);
if (pos.n == _begin)
_begin = _begin->next();
pos.n->remove ();
delete pos.n;
pos.n = 0;
--_length;
}
}
void erase (iterator first, iterator last)
{
iterator next;
while (first != last) {
next = first;
++next;
// XXX first must be incremented before erasing!
erase (first);
first = next;
}
}
};
template<class T>
bool operator== (const list<T> &v1, const list<T> &v2)
{
if (v1.size() != v2.size())
return false;
typename list<T>::const_iterator i1 = v1.begin();
typename list<T>::const_iterator i2 = v2.begin();
for ( ;i1 != v1.end() && i2 != v2.end(); ++i1, ++i2) {
if (!(*i1 == *i2))
return false;
}
return true;
}
template<class T>
bool operator< (const list<T> &v1, const list<T> &v2)
{
long minlast = _min_ (v1.size(), v2.size());
typename list<T>::const_iterator i1 = v1.begin();
typename list<T>::const_iterator i2 = v2.begin();
for ( ;i1 != v1.end() && i2 != v2.end(); ++i1, ++i2) {
if (!(*i1 == *i2))
return *i1 < *i2;
}
return v1.size() < v2.size();
}
#endif // __ministl_list_h__

23
ministl/map Normal file
View File

@ -0,0 +1,23 @@
/*
* MICO --- a free CORBA implementation
* Copyright (C) 1997-98 Kay Roemer & Arno Puder
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Send comments and/or bug reports to:
* mico@informatik.uni-frankfurt.de
*/
#include <ministl/map.h>

374
ministl/map.h Normal file
View File

@ -0,0 +1,374 @@
// -*- c++ -*-
/*
* MICO --- a free CORBA implementation
* Copyright (C) 1997-98 Kay Roemer & Arno Puder
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Send comments and/or bug reports to:
* mico@informatik.uni-frankfurt.de
*/
#ifndef __ministl_map_h__
#define __ministl_map_h__
#include <ministl/ministl.h>
#include <ministl/simplevec.h>
#include <ministl/function>
#include <ministl/pair>
#ifndef __GNUG__
#include <ministl/bool.h>
#endif
template<class kT, class vT, class cT> class map;
template<class kT, class vT, class cT> class mapConstIterator;
template<class kT, class vT, class cT>
class mapIterator {
friend class map<kT,vT,cT>;
friend class mapConstIterator<kT,vT,cT>;
typedef mapIterator<kT,vT,cT> my_type;
typedef pair<const kT, vT> value_type;
typedef simplevec<value_type *> rep_type;
typedef typename rep_type::iterator repiterator;
repiterator n;
mapIterator (repiterator _n)
: n (_n)
{
}
public:
mapIterator ()
: n (0)
{
}
bool operator== (const my_type &it) const
{
return it.n == n;
}
bool operator!= (const my_type &it) const
{
return !(it.n == n);
}
my_type operator++ ()
{
++n;
return *this;
}
my_type operator++ (int)
{
my_type tmp = *this;
++n;
return tmp;
}
my_type operator-- ()
{
--n;
return *this;
}
my_type operator-- (int)
{
my_type tmp = *this;
--n;
return tmp;
}
value_type &operator* ()
{
return **n;
}
};
template<class kT, class vT, class cT>
class mapConstIterator {
friend class map<kT,vT,cT>;
typedef mapConstIterator<kT,vT,cT> my_type;
typedef pair<const kT, vT> value_type;
typedef simplevec<value_type *> rep_type;
typedef typename rep_type::const_iterator repiterator;
repiterator n;
mapConstIterator (repiterator _n)
: n (_n)
{
}
public:
mapConstIterator ()
: n (0)
{
}
mapConstIterator (const mapIterator<kT,vT,cT> &i)
: n (i.n)
{
}
bool operator== (const my_type &it) const
{
return it.n == n;
}
bool operator!= (const my_type &it) const
{
return !(it.n == n);
}
my_type operator++ ()
{
++n;
return *this;
}
my_type operator++ (int)
{
my_type tmp = *this;
++n;
return tmp;
}
my_type operator-- ()
{
--n;
return *this;
}
my_type operator-- (int)
{
my_type tmp = *this;
--n;
return tmp;
}
const value_type &operator* () const
{
return **n;
}
};
template<class keyT, class valT, class cmpT>
class map {
public:
typedef keyT key_type;
typedef pair<const keyT, valT> value_type;
typedef unsigned long size_type;
typedef simplevec<value_type *> rep_type;
typedef mapIterator<keyT, valT, cmpT> iterator;
typedef mapConstIterator<keyT, valT, cmpT> const_iterator;
// XXX typedefs done to work around g++ bug
typedef pair<iterator, bool> pair_iterator_bool;
private:
rep_type _ents;
cmpT _comp;
public:
iterator begin ()
{
return iterator (_ents.begin());
}
const_iterator begin () const
{
return const_iterator (_ents.begin());
}
iterator end ()
{
return iterator (_ents.end());
}
const_iterator end () const
{
return const_iterator (_ents.end());
}
map (const cmpT &comp = cmpT())
: _comp (comp)
{
}
map (const_iterator first, const_iterator last, const cmpT &comp = cmpT())
: _comp (comp)
{
insert (first, last);
}
map (const map<keyT, valT, cmpT> &m)
: _comp (m._comp)
{
insert (m.begin(), m.end());
}
map<keyT, valT, cmpT> &operator= (const map<keyT, valT, cmpT> &m)
{
if (this != &m) {
_comp = m._comp;
erase (begin(), end());
insert (m.begin(), m.end());
}
return *this;
}
~map ()
{
erase (begin(), end());
}
bool empty () const
{
return _ents.empty ();
}
size_type size () const
{
return _ents.size ();
}
private:
// find the iterator position where k should be inserted ...
bool lookup (const key_type &k, iterator &it);
public:
pair_iterator_bool insert (const value_type &v)
{
iterator i = end();
if (size() > 0 && lookup (v.first, i))
return pair_iterator_bool (i, false);
i = iterator (_ents.insert (i.n, new value_type (v)));
return pair_iterator_bool (i, true);
}
#if 0
iterator insert (iterator pos, const value_type &v)
{
}
#endif
void insert (const_iterator first, const_iterator last)
{
for ( ; first != last; ++first)
insert (*first);
}
void insert (const value_type *first, const value_type *last)
{
for ( ; first != last; ++first)
insert (*first);
}
void erase (iterator pos)
{
if (pos != end()) {
delete *(pos.n);
_ents.erase (pos.n);
}
}
size_type erase (const key_type &k)
{
iterator i = find (k);
if (i == end())
return 0;
erase (i);
return 1;
}
void erase (iterator first, iterator last)
{
for (iterator i = first; i != last; ++i)
delete *(i.n);
_ents.erase (first.n, last.n);
}
void clear ()
{
erase (begin(), end());
}
iterator find (const key_type &k)
{
if (size() > 0) {
int l = 0;
int r = size()-1;
do {
int m = (l+r) >> 1;
if (_comp (_ents[m]->first, k)) {
l = m+1;
} else {
// if (k == _ents[m]->first)
if (!_comp (k, _ents[m]->first))
return iterator (_ents.begin()+m);
r = m-1;
}
} while (l <= r);
}
return end();
}
const_iterator find (const key_type &k) const
{
if (size() > 0) {
int l = 0;
int r = size()-1;
do {
int m = (l+r) >> 1;
if (_comp (_ents[m]->first, k)) {
l = m+1;
} else {
// if (k == _ents[m]->first)
if (!_comp (k, _ents[m]->first))
return const_iterator (_ents.begin()+m);
r = m-1;
}
} while (l <= r);
}
return end();
}
size_type count (const key_type &k) const
{
return find (k) != end() ? 1 : 0;
}
valT &operator[] (const key_type &k)
{
iterator i = insert(value_type (k, valT())).first;
return (*i).second;
}
};
template<class kT, class vT, class cT>
inline bool
map<kT,vT,cT>::lookup (const kT &k, mapIterator<kT,vT,cT> &it)
{
int l = 0;
int r = size();
while (l < r) {
int m = (l+r) >> 1;
ministl_assert (m < r);
if (_comp (_ents[m]->first, k)) {
l = m+1;
} else {
// if (k == _ents[m]->first) {
if (!_comp (k, _ents[m]->first)) {
it = mapIterator<kT,vT,cT> (_ents.begin()+m);
return true;
}
r = m;
}
}
ministl_assert (l == r);
it = mapIterator<kT,vT,cT> (_ents.begin()+l);
return l < (int)size() &&
// (*it).first == k;
!_comp ((*it).first, k) && !_comp (k, (*it).first);
}
template<class kT, class vT, class cT>
bool operator== (const map<kT,vT,cT> &v1, const map<kT,vT,cT> &v2)
{
if (v1.size() != v2.size())
return false;
typename map<kT,vT,cT>::const_iterator i1 = v1.begin();
typename map<kT,vT,cT>::const_iterator i2 = v2.begin();
for ( ;i1 != v1.end() && i2 != v2.end(); ++i1, ++i2) {
if (!(*i1 == *i2))
return false;
}
return true;
}
template<class kT, class vT, class cT>
bool operator< (const map<kT,vT,cT> &v1, const map<kT,vT,cT> &v2)
{
long minlast = _min_ (v1.size(), v2.size());
typename map<kT,vT,cT>::const_iterator i1 = v1.begin();
typename map<kT,vT,cT>::const_iterator i2 = v2.begin();
for ( ;i1 != v1.end() && i2 != v2.end(); ++i1, ++i2) {
if (*i1 < *i2)
return true;
if (*i2 < *i1)
return false;
}
return v1.size() < v2.size();
}
#endif // __ministl_map_h__

48
ministl/ministl.h Normal file
View File

@ -0,0 +1,48 @@
// -*- c++ -*-
/*
* MICO --- a free CORBA implementation
* Copyright (C) 1997-98 Kay Roemer & Arno Puder
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Send comments and/or bug reports to:
* mico@informatik.uni-frankfurt.de
*/
#ifndef __ministl_ministl_h__
#define __ministl_ministl_h__
#ifndef assert
#include <assert.h>
#endif
#ifdef MINISTL_NDEBUG
#define ministl_assert(exp)
#else
#define ministl_assert(exp) assert(exp)
#endif
static inline long _min_ (long x, long y)
{
return x < y ? x : y;
}
static inline long _max_ (long x, long y)
{
return x > y ? x : y;
}
#endif // __ministl_ministl_h__

23
ministl/pair Normal file
View File

@ -0,0 +1,23 @@
/*
* MICO --- a free CORBA implementation
* Copyright (C) 1997-98 Kay Roemer & Arno Puder
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Send comments and/or bug reports to:
* mico@informatik.uni-frankfurt.de
*/
#include <ministl/pair.h>

51
ministl/pair.h Normal file
View File

@ -0,0 +1,51 @@
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*/
#ifndef PAIR_H
#define PAIR_H
#ifndef __GNUG__
#include <ministl/bool.h>
#endif
template <class T1, class T2>
struct pair {
T1 first;
T2 second;
#if defined(_AIX) && !defined(__GNUG__)
// if T? is const xlC goofes about first/second not beeing inited
pair() : first (T1()), second (T2()) {}
#else
pair() {}
#endif
pair(const T1& a, const T2& b) : first(a), second(b) {}
};
template <class T1, class T2>
inline bool operator==(const pair<T1, T2>& x, const pair<T1, T2>& y) {
return x.first == y.first && x.second == y.second;
}
template <class T1, class T2>
inline bool operator<(const pair<T1, T2>& x, const pair<T1, T2>& y) {
return x.first < y.first || (!(y.first < x.first) && x.second < y.second);
}
template <class T1, class T2>
inline pair<T1, T2> make_pair(const T1& x, const T2& y) {
return pair<T1, T2>(x, y);
}
#endif

23
ministl/set Normal file
View File

@ -0,0 +1,23 @@
/*
* MICO --- a free CORBA implementation
* Copyright (C) 1997-98 Kay Roemer & Arno Puder
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Send comments and/or bug reports to:
* mico@informatik.uni-frankfurt.de
*/
#include <ministl/set.h>

368
ministl/set.h Normal file
View File

@ -0,0 +1,368 @@
// -*- c++ -*-
/*
* MICO --- a free CORBA implementation
* Copyright (C) 1997-98 Kay Roemer & Arno Puder
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Send comments and/or bug reports to:
* mico@informatik.uni-frankfurt.de
*/
#ifndef __ministl_set_h__
#define __ministl_set_h__
#include <ministl/ministl.h>
#include <ministl/simplevec.h>
#include <ministl/function>
#include <ministl/pair>
#ifndef __GNUG__
#include <ministl/bool.h>
#endif
template<class vT, class cT> class set;
template<class vT, class cT> class setConstIterator;
template<class vT, class cT>
class setIterator {
friend class set<vT,cT>;
friend class setConstIterator<vT,cT>;
typedef setIterator<vT,cT> my_type;
typedef vT value_type;
typedef simplevec<value_type *> rep_type;
typedef typename rep_type::iterator repiterator;
repiterator n;
setIterator (repiterator _n)
: n (_n)
{
}
public:
setIterator ()
: n (0)
{
}
bool operator== (const my_type &it) const
{
return it.n == n;
}
bool operator!= (const my_type &it) const
{
return !(it.n == n);
}
my_type operator++ ()
{
++n;
return *this;
}
my_type operator++ (int)
{
my_type tmp = *this;
++n;
return tmp;
}
my_type operator-- ()
{
--n;
return *this;
}
my_type operator-- (int)
{
my_type tmp = *this;
--n;
return tmp;
}
value_type &operator* ()
{
return **n;
}
};
template<class vT, class cT>
class setConstIterator {
friend class set<vT,cT>;
typedef setConstIterator<vT,cT> my_type;
typedef vT value_type;
typedef simplevec<value_type *> rep_type;
typedef typename rep_type::const_iterator repiterator;
repiterator n;
setConstIterator (repiterator _n)
: n (_n)
{
}
public:
setConstIterator ()
: n (0)
{
}
setConstIterator (const setIterator<vT,cT> &i)
: n (i.n)
{
}
bool operator== (const my_type &it) const
{
return it.n == n;
}
bool operator!= (const my_type &it) const
{
return !(it.n == n);
}
my_type operator++ ()
{
++n;
return *this;
}
my_type operator++ (int)
{
my_type tmp = *this;
++n;
return tmp;
}
my_type operator-- ()
{
--n;
return *this;
}
my_type operator-- (int)
{
my_type tmp = *this;
--n;
return tmp;
}
const value_type &operator* () const
{
return **n;
}
};
template<class valT, class cmpT>
class set {
public:
typedef valT value_type;
typedef unsigned long size_type;
typedef simplevec<value_type *> rep_type;
typedef setIterator<valT, cmpT> iterator;
typedef setConstIterator<valT, cmpT> const_iterator;
// XXX typedefs done to work around g++ bug
typedef pair<iterator, bool> pair_iterator_bool;
private:
rep_type _ents;
cmpT _comp;
public:
iterator begin ()
{
return iterator (_ents.begin());
}
const_iterator begin () const
{
return const_iterator (_ents.begin());
}
iterator end ()
{
return iterator (_ents.end());
}
const_iterator end () const
{
return const_iterator (_ents.end());
}
set (const cmpT &comp = cmpT())
: _comp (comp)
{
}
set (const_iterator first, const_iterator last, const cmpT &comp = cmpT())
: _comp (comp)
{
insert (first, last);
}
set (const set<valT, cmpT> &m)
: _comp (m._comp)
{
insert (m.begin(), m.end());
}
set<valT, cmpT> &operator= (const set<valT, cmpT> &m)
{
if (this != &m) {
_comp = m._comp;
erase (begin(), end());
insert (m.begin(), m.end());
}
return *this;
}
~set ()
{
erase (begin(), end());
}
bool empty () const
{
return _ents.empty ();
}
size_type size () const
{
return _ents.size ();
}
private:
// find the iterator position where k should be inserted ...
bool lookup (const value_type &k, iterator &it);
public:
pair_iterator_bool insert (const value_type &v)
{
iterator i = end();
if (size() > 0 && lookup (v, i))
return pair_iterator_bool (i, false);
i = iterator (_ents.insert (i.n, new value_type (v)));
return pair_iterator_bool (i, true);
}
#if 0
iterator insert (iterator pos, const value_type &v)
{
}
#endif
void insert (const_iterator first, const_iterator last)
{
for ( ; first != last; ++first)
insert (*first);
}
void insert (const value_type *first, const value_type *last)
{
for ( ; first != last; ++first)
insert (*first);
}
void erase (iterator pos)
{
if (pos != end()) {
delete *(pos.n);
_ents.erase (pos.n);
}
}
size_type erase (const value_type &k)
{
iterator i = find (k);
if (i == end())
return 0;
erase (i);
return 1;
}
void erase (iterator first, iterator last)
{
for (iterator i = first; i != last; ++i)
delete *(i.n);
_ents.erase (first.n, last.n);
}
void clear ()
{
erase (begin(), end());
}
iterator find (const value_type &k)
{
if (size() > 0) {
int l = 0;
int r = size()-1;
do {
int m = (l+r) >> 1;
if (_comp (*_ents[m], k)) {
l = m+1;
} else {
// if (k == *_ents[m])
if (!_comp (k, *_ents[m]))
return iterator (_ents.begin()+m);
r = m-1;
}
} while (l <= r);
}
return end();
}
const_iterator find (const value_type &k) const
{
if (size() > 0) {
int l = 0;
int r = size()-1;
do {
int m = (l+r) >> 1;
if (_comp (*_ents[m], k)) {
l = m+1;
} else {
// if (k == *_ents[m])
if (!_comp (k, *_ents[m]))
return const_iterator (_ents.begin()+m);
r = m-1;
}
} while (l <= r);
}
return end();
}
size_type count (const value_type &k) const
{
return find (k) != end() ? 1 : 0;
}
};
template<class vT, class cT>
inline bool
set<vT, cT>::lookup (const vT &k, setIterator<vT,cT> &it)
{
int l = 0;
int r = size();
while (l < r) {
int m = (l+r) >> 1;
ministl_assert (m < r);
if (_comp (*_ents[m], k)) {
l = m+1;
} else {
// if (k == *_ents[m]) {
if (!_comp (k, *_ents[m])) {
it = setIterator<vT,cT> (_ents.begin()+m);
return true;
}
r = m;
}
}
ministl_assert (l == r);
it = setIterator<vT,cT> (_ents.begin()+l);
return l < (int)size() &&
// k == *it
!_comp (*it, k) && !_comp (k, *it);
}
template<class vT, class cT>
bool operator== (const set<vT,cT> &v1, const set<vT,cT> &v2)
{
if (v1.size() != v2.size())
return false;
typename set<vT,cT>::const_iterator i1 = v1.begin();
typename set<vT,cT>::const_iterator i2 = v2.begin();
for ( ;i1 != v1.end() && i2 != v2.end(); ++i1, ++i2) {
if (!(*i1 == *i2))
return false;
}
return true;
}
template<class vT, class cT>
bool operator< (const set<vT,cT> &v1, const set<vT,cT> &v2)
{
long minlast = _min_ (v1.size(), v2.size());
typename set<vT,cT>::const_iterator i1 = v1.begin();
typename set<vT,cT>::const_iterator i2 = v2.begin();
for ( ;i1 != v1.end() && i2 != v2.end(); ++i1, ++i2) {
if (*i1 < *i2)
return true;
if (*i2 < *i1)
return false;
}
return v1.size() < v2.size();
}
#endif // __ministl_set_h__

270
ministl/simplevec.h Normal file
View File

@ -0,0 +1,270 @@
// -*- c++ -*-
/*
* MICO --- a free CORBA implementation
* Copyright (C) 1997-98 Kay Roemer & Arno Puder
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Send comments and/or bug reports to:
* mico@informatik.uni-frankfurt.de
*/
#ifndef __ministl_simplevec_h__
#define __ministl_simplevec_h__
#include <ministl/ministl.h>
#ifndef __GNUG__
#include <ministl/bool.h>
#endif
#include <ministl/defalloc.h>
template<class T>
class simplevec {
public:
typedef T* iterator;
typedef const T* const_iterator;
typedef unsigned long size_type;
private:
size_type _last, _size;
T *_buf;
public:
const_iterator begin () const
{
return &_buf[0];
}
iterator begin ()
{
return &_buf[0];
}
const_iterator end () const
{
return &_buf[_last];
}
iterator end ()
{
return &_buf[_last];
}
size_type capacity () const
{
return _size;
}
size_type size () const
{
return _last;
}
private:
static T *alloc (size_type n)
{
return (T *)::operator new ((size_t)(n * sizeof (T)));
}
static void dealloc (T *buf)
{
if (buf)
::operator delete (buf);
}
void reserve (iterator where, size_type n)
{
if (_last + n <= _size) {
memmove (where+n, where, (end()-where)*sizeof(T));
} else {
long sz = _last+n;
sz = (_size == 0) ? _max_(sz, 5) : _max_(sz, 2*_size);
T *nbuf = alloc (sz);
if (_buf) {
memcpy (nbuf, begin(), (where-begin())*sizeof(T));
memcpy (nbuf + (where-begin()) + n, where,
(end()-where)*sizeof(T));
dealloc (_buf);
}
_buf = nbuf;
_size = sz;
}
}
public:
void reserve (size_type sz)
{
if (_size < sz) {
sz = (_size == 0) ? _max_(sz, 5) : _max_(sz, 2*_size);
T *nbuf = alloc (sz);
if (_buf) {
memcpy (nbuf, begin(), size()*sizeof(T));
dealloc (_buf);
}
_buf = nbuf;
_size = sz;
}
}
simplevec ()
: _last (0), _size (0), _buf (0)
{
}
simplevec (size_type n, const T& t = T())
: _last (0), _size (0), _buf (0)
{
insert (begin(), n, t);
}
simplevec (const_iterator first, const_iterator last)
: _last (0), _size (0), _buf (0)
{
insert (begin(), first, last);
}
simplevec (const simplevec<T> &v)
: _last (0), _size (0), _buf (0)
{
reserve (v._last);
memcpy (_buf, v.begin(), v.size()*sizeof(T));
_last = v._last;
}
simplevec<T> &operator= (const simplevec<T> &v)
{
if (this != &v) {
_last = 0;
reserve (v._last);
memcpy (_buf, v.begin(), v.size()*sizeof(T));
_last = v._last;
}
return *this;
}
~simplevec ()
{
dealloc (_buf);
}
const T &front () const
{
//ministl_assert (size() > 0);
return _buf[0];
}
T &front ()
{
//ministl_assert (size() > 0);
return _buf[0];
}
const T &back () const
{
//ministl_assert (size() > 0);
return _buf[_last-1];
}
T &back ()
{
//ministl_assert (size() > 0);
return _buf[_last-1];
}
bool empty () const
{
return _last == 0;
}
void clear ()
{
_last = 0;
}
void push_back (const T &t)
{
reserve (_last+1);
*end() = t;
++_last;
}
void pop_back ()
{
//ministl_assert (size() > 0);
--_last;
}
const T &operator[] (size_type idx) const
{
//ministl_assert (idx < size());
return _buf[idx];
}
T &operator[] (size_type idx)
{
//ministl_assert (idx < size());
return _buf[idx];
}
iterator insert (iterator pos, const T &t)
{
//ministl_assert (pos <= end());
long at = pos - begin();
reserve (pos, 1);
pos = begin()+at;
*pos = t;
++_last;
return pos;
}
iterator insert (iterator pos, const_iterator first, const_iterator last)
{
//ministl_assert (pos <= end());
long n = last - first;
long at = pos - begin();
if (n > 0) {
reserve (pos, n);
pos = begin()+at;
memcpy (pos, first, (last-first)*sizeof(T));
_last += n;
}
return pos;
}
iterator insert (iterator pos, size_type n, const T &t)
{
//ministl_assert (pos <= end());
long at = pos - begin();
if (n > 0) {
reserve (pos, n);
pos = begin()+at;
for (int i = 0; i < n; ++i)
pos[i] = t;
_last += n;
}
return pos;
}
void erase (iterator first, iterator last)
{
if (last != first) {
memmove (first, last, (end()-last)*sizeof(T));
_last -= last - first;
}
}
void erase (iterator pos)
{
if (pos != end()) {
memmove (pos, pos+1, (end()-(pos+1))*sizeof(T));
--_last;
}
}
};
template<class T>
bool operator== (const simplevec<T> &v1, const simplevec<T> &v2)
{
if (v1.size() != v2.size())
return false;
return !v1.size() || !memcmp (&v1[0], &v2[0], v1.size()*sizeof(T));
}
template<class T>
bool operator< (const simplevec<T> &v1, const simplevec<T> &v2)
{
unsigned long minlast = _min_ (v1.size(), v2.size());
for (unsigned long i = 0; i < minlast; ++i) {
if (v1[i] < v2[i])
return true;
if (v2[i] < v1[i])
return false;
}
return v1.size() < v2.size();
}
#endif

23
ministl/string Normal file
View File

@ -0,0 +1,23 @@
/*
* MICO --- a free CORBA implementation
* Copyright (C) 1997-98 Kay Roemer & Arno Puder
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Send comments and/or bug reports to:
* mico@informatik.uni-frankfurt.de
*/
#include <ministl/bstring.h>

23
ministl/vector Normal file
View File

@ -0,0 +1,23 @@
/*
* MICO --- a free CORBA implementation
* Copyright (C) 1997-98 Kay Roemer & Arno Puder
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Send comments and/or bug reports to:
* mico@informatik.uni-frankfurt.de
*/
#include <ministl/vector.h>

318
ministl/vector.h Normal file
View File

@ -0,0 +1,318 @@
// -*- c++ -*-
/*
* MICO --- a free CORBA implementation
* Copyright (C) 1997-98 Kay Roemer & Arno Puder
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Send comments and/or bug reports to:
* mico@informatik.uni-frankfurt.de
*/
#ifndef __ministl_vector_h__
#define __ministl_vector_h__
#include <ministl/ministl.h>
#ifndef __GNUG__
#include <ministl/bool.h>
#endif
#include <ministl/defalloc.h>
template<class T>
class vector {
public:
typedef T* iterator;
typedef const T* const_iterator;
typedef unsigned long size_type;
private:
size_type _last, _size;
T *_buf;
public:
const_iterator begin () const
{
return &_buf[0];
}
iterator begin ()
{
return &_buf[0];
}
const_iterator end () const
{
return &_buf[_last];
}
iterator end ()
{
return &_buf[_last];
}
size_type capacity () const
{
return _size;
}
size_type size () const
{
return _last;
}
private:
static T *alloc (size_type n)
{
return (T *)::operator new ((size_t)(n * sizeof (T)));
}
static void dealloc (T *buf)
{
if (buf)
::operator delete (buf);
}
// overlapping move to the right
static void copy_forward (T* d, const T* sstart, const T* send)
{
d += send - sstart;
while (send != sstart)
*--d = *--send;
}
// overlapping move to the left
static void copy_backward (T* d, const T* sstart, const T* send)
{
for ( ; send != sstart; ++d, ++sstart)
*d = *sstart;
}
static void construct (T *d, const T &t)
{
new (d) T(t);
}
static void construct (T *d, const T *sstart, const T *send)
{
for ( ; sstart != send; ++sstart, ++d)
construct (d, *sstart);
}
static void fill (iterator d, size_type n, const T &t)
{
for (size_type i = 0; i < n; ++i, ++d)
construct (d, t);
}
void reserve (iterator where, size_type n)
{
if (_last + n <= _size) {
if (where+n < end()) {
construct (end(), end()-n, end());
copy_forward (where+n, where, end()-n);
destroy (where, where+n);
} else {
construct (where+n, where, end());
destroy (where, end());
}
} else {
long sz = _last+n;
sz = (_size == 0) ? _max_(sz, 5) : _max_(sz, 2*_size);
T *nbuf = alloc (sz);
if (_buf) {
construct (nbuf, begin(), where);
construct (nbuf + (where-begin()) + n, where, end());
destroy (begin(), end());
dealloc (_buf);
}
_buf = nbuf;
_size = sz;
}
}
public:
void reserve (size_type sz)
{
if (_size < sz) {
sz = (_size == 0) ? _max_(sz, 5) : _max_(sz, 2*_size);
T *nbuf = alloc (sz);
if (_buf) {
construct (nbuf, begin(), end());
destroy (begin(), end());
dealloc (_buf);
}
_buf = nbuf;
_size = sz;
}
}
vector ()
: _last (0), _size (0), _buf (0)
{
}
vector (size_type n, const T& t = T())
: _last (0), _size (0), _buf (0)
{
insert (begin(), n, t);
}
vector (const_iterator first, const_iterator last)
: _last (0), _size (0), _buf (0)
{
insert (begin(), first, last);
}
vector (const vector<T> &v)
: _last (0), _size (0), _buf (0)
{
reserve (v._last);
construct (begin(), v.begin(), v.end());
_last = v._last;
}
vector<T> &operator= (const vector<T> &v)
{
if (this != &v) {
destroy (begin(), end());
_last = 0;
reserve (v._last);
construct (begin(), v.begin(), v.end());
_last = v._last;
}
return *this;
}
~vector ()
{
destroy (begin(), end());
dealloc (_buf);
}
const T &front () const
{
ministl_assert (size() > 0);
return _buf[0];
}
T &front ()
{
ministl_assert (size() > 0);
return _buf[0];
}
const T &back () const
{
ministl_assert (size() > 0);
return _buf[_last-1];
}
T &back ()
{
ministl_assert (size() > 0);
return _buf[_last-1];
}
bool empty () const
{
return _last == 0;
}
void clear ()
{
destroy (begin(), end());
_last = 0;
}
void push_back (const T &t)
{
reserve (_last+1);
construct (end(), t);
++_last;
}
void pop_back ()
{
ministl_assert (size() > 0);
--_last;
destroy (end());
}
const T &operator[] (size_type idx) const
{
ministl_assert (idx < size());
return _buf[idx];
}
T &operator[] (size_type idx)
{
ministl_assert (idx < size());
return _buf[idx];
}
iterator insert (iterator pos, const T &t)
{
ministl_assert (pos <= end());
long at = pos - begin();
reserve (pos, 1);
pos = begin()+at;
construct (pos, t);
++_last;
return pos;
}
iterator insert (iterator pos, const_iterator first, const_iterator last)
{
ministl_assert (pos <= end());
long n = last - first;
long at = pos - begin();
if (n > 0) {
reserve (pos, n);
pos = begin()+at;
construct (pos, first, last);
_last += n;
}
return pos;
}
iterator insert (iterator pos, size_type n, const T &t)
{
ministl_assert (pos <= end());
long at = pos - begin();
if (n > 0) {
reserve (pos, n);
pos = begin()+at;
fill (pos, n, t);
_last += n;
}
return pos;
}
void erase (iterator first, iterator last)
{
if (last != first) {
copy_backward (first, last, end());
destroy (end() - (last-first), end());
_last -= last - first;
}
}
void erase (iterator pos)
{
if (pos != end()) {
copy_backward (pos, pos+1, end());
destroy (end()-1);
--_last;
}
}
};
template<class T>
bool operator== (const vector<T> &v1, const vector<T> &v2)
{
if (v1.size() != v2.size())
return false;
for (unsigned long i = 0; i < v1.size(); ++i) {
if (!(v1[i] == v2[i]))
return false;
}
return true;
}
template<class T>
bool operator< (const vector<T> &v1, const vector<T> &v2)
{
unsigned long minlast = _min_ (v1.size(), v2.size());
for (unsigned long i = 0; i < minlast; ++i) {
if (v1[i] < v2[i])
return true;
if (v2[i] < v1[i])
return false;
}
return v1.size() < v2.size();
}
#endif