1e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh/* 2e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * Copyright (C) 2008 The Android Open Source Project 3e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * All rights reserved. 4e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * 5e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * Redistribution and use in source and binary forms, with or without 6e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * modification, are permitted provided that the following conditions 7e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * are met: 8e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * * Redistributions of source code must retain the above copyright 9e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * notice, this list of conditions and the following disclaimer. 10e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * * Redistributions in binary form must reproduce the above copyright 11e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * notice, this list of conditions and the following disclaimer in 12e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * the documentation and/or other materials provided with the 13e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * distribution. 14e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * 15e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 22e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * SUCH DAMAGE. 27e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh */ 28e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh/* 29e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * 30e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * Copyright (c) 1994 31e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * Hewlett-Packard Company 32e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * 33e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * Permission to use, copy, modify, distribute and sell this software 34e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * and its documentation for any purpose is hereby granted without fee, 35e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * provided that the above copyright notice appear in all copies and 36e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * that both that copyright notice and this permission notice appear 37e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * in supporting documentation. Hewlett-Packard Company makes no 38e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * representations about the suitability of this software for any 39e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * purpose. It is provided "as is" without express or implied warranty. 40e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * 41e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * 42e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * Copyright (c) 1996,1997 43e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * Silicon Graphics Computer Systems, Inc. 44e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * 45e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * Permission to use, copy, modify, distribute and sell this software 46e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * and its documentation for any purpose is hereby granted without fee, 47e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * provided that the above copyright notice appear in all copies and 48e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * that both that copyright notice and this permission notice appear 49e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * in supporting documentation. Silicon Graphics makes no 50e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * representations about the suitability of this software for any 51e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * purpose. It is provided "as is" without express or implied warranty. 52e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh */ 53e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh 54e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh/* NOTE: This is an internal header file, included by other STL headers. 55e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh * You should not attempt to use it directly. 56e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh */ 57e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh 58e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh#ifndef __SGI_STL_INTERNAL_PAIR_H 59e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh#define __SGI_STL_INTERNAL_PAIR_H 60e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh 61e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh#ifndef __STL_BEGIN_NAMESPACE 62e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh#define __STL_BEGIN_NAMESPACE namespace std { 63e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh#endif 64e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh 65e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh#ifndef __STL_END_NAMESPACE 66e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh#define __STL_END_NAMESPACE } 67e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh#endif 68e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh 69e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh__STL_BEGIN_NAMESPACE 70e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh 71e7de7d971409d955ca138406d5062499bc554451Andrew Hsiehtemplate <class _T1, class _T2> 72e7de7d971409d955ca138406d5062499bc554451Andrew Hsiehstruct pair { 73e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh typedef _T1 first_type; 74e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh typedef _T2 second_type; 75e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh 76e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh _T1 first; 77e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh _T2 second; 78e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh pair() : first(), second() {} 79e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {} 80e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh 81e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh template <class _U1, class _U2> 82e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {} 83e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh}; 84e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh 85e7de7d971409d955ca138406d5062499bc554451Andrew Hsiehtemplate <class _T1, class _T2> 86e7de7d971409d955ca138406d5062499bc554451Andrew Hsiehinline bool operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) 87e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh{ 88e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh return __x.first == __y.first && __x.second == __y.second; 89e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh} 90e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh 91e7de7d971409d955ca138406d5062499bc554451Andrew Hsiehtemplate <class _T1, class _T2> 92e7de7d971409d955ca138406d5062499bc554451Andrew Hsiehinline bool operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) 93e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh{ 94e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh return __x.first < __y.first || 95e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh (!(__y.first < __x.first) && __x.second < __y.second); 96e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh} 97e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh 98e7de7d971409d955ca138406d5062499bc554451Andrew Hsiehtemplate <class _T1, class _T2> 99e7de7d971409d955ca138406d5062499bc554451Andrew Hsiehinline bool operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) { 100e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh return !(__x == __y); 101e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh} 102e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh 103e7de7d971409d955ca138406d5062499bc554451Andrew Hsiehtemplate <class _T1, class _T2> 104e7de7d971409d955ca138406d5062499bc554451Andrew Hsiehinline bool operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) { 105e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh return __y < __x; 106e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh} 107e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh 108e7de7d971409d955ca138406d5062499bc554451Andrew Hsiehtemplate <class _T1, class _T2> 109e7de7d971409d955ca138406d5062499bc554451Andrew Hsiehinline bool operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) { 110e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh return !(__y < __x); 111e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh} 112e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh 113e7de7d971409d955ca138406d5062499bc554451Andrew Hsiehtemplate <class _T1, class _T2> 114e7de7d971409d955ca138406d5062499bc554451Andrew Hsiehinline bool operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) { 115e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh return !(__x < __y); 116e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh} 117e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh 118e7de7d971409d955ca138406d5062499bc554451Andrew Hsiehtemplate <class _T1, class _T2> 119e7de7d971409d955ca138406d5062499bc554451Andrew Hsiehinline pair<_T1, _T2> make_pair(_T1 __x, _T2 __y) 120e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh{ 121e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh return pair<_T1, _T2>(__x, __y); 122e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh} 123e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh 124e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh__STL_END_NAMESPACE 125e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh 126e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh#endif /* __SGI_STL_INTERNAL_PAIR_H */ 127e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh 128e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// Local Variables: 129e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// mode:C++ 130e7de7d971409d955ca138406d5062499bc554451Andrew Hsieh// End: 131