|
||||
File indexing completed on 2024-11-15 09:59:09
0001 0002 /*--------------------------------------------------------------------*/ 0003 /*--- An sparse array (of words) implementation. ---*/ 0004 /*--- pub_tool_sparsewa.h ---*/ 0005 /*--------------------------------------------------------------------*/ 0006 0007 /* 0008 This file is part of Valgrind, a dynamic binary instrumentation 0009 framework. 0010 0011 Copyright (C) 2008-2017 OpenWorks Ltd 0012 info@open-works.co.uk 0013 0014 This program is free software; you can redistribute it and/or 0015 modify it under the terms of the GNU General Public License as 0016 published by the Free Software Foundation; either version 2 of the 0017 License, or (at your option) any later version. 0018 0019 This program is distributed in the hope that it will be useful, but 0020 WITHOUT ANY WARRANTY; without even the implied warranty of 0021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0022 General Public License for more details. 0023 0024 You should have received a copy of the GNU General Public License 0025 along with this program; if not, see <http://www.gnu.org/licenses/>. 0026 0027 The GNU General Public License is contained in the file COPYING. 0028 */ 0029 0030 #ifndef __PUB_TOOL_SPARSEWA_H 0031 #define __PUB_TOOL_SPARSEWA_H 0032 0033 #include "pub_tool_basics.h" // UWord 0034 0035 //-------------------------------------------------------------------- 0036 // PURPOSE: (see coregrind/pub_core_sparsewa.h for details) 0037 //-------------------------------------------------------------------- 0038 0039 ///////////////////////////////////////////////////////// 0040 // // 0041 // SparseWA: Interface // 0042 // // 0043 ///////////////////////////////////////////////////////// 0044 0045 // This interface is a very cut-down version of WordFM. 0046 // If you understand how to use WordFM then it should be 0047 // trivial to use SparseWA. 0048 0049 typedef struct _SparseWA SparseWA; /* opaque */ 0050 0051 // Create a new one, using the specified allocator/deallocator. 0052 // Never returns NULL. 0053 SparseWA* VG_(newSWA) ( void*(*alloc_nofail)(const HChar* cc, SizeT), 0054 const HChar* cc, 0055 void(*dealloc)(void*) ); 0056 0057 // Delete one, and free all associated storage 0058 void VG_(deleteSWA) ( SparseWA* swa ); 0059 0060 // Add the binding key -> val to this swa. Any existing binding is 0061 // overwritten. Returned Bool is True iff a previous binding existed. 0062 Bool VG_(addToSWA) ( SparseWA* swa, UWord key, UWord val ); 0063 0064 // Delete key from swa, returning val if found. 0065 // Returned Bool is True iff the key was actually bound in the mapping. 0066 Bool VG_(delFromSWA) ( SparseWA* swa, 0067 /*OUT*/UWord* oldV, 0068 UWord key ); 0069 0070 // Indexes swa at 'key' (or, if you like, looks up 'key' in the 0071 // mapping), and returns the associated value, if any, in *valP. 0072 // Returned Bool is True iff a binding for 'key' actually existed. 0073 Bool VG_(lookupSWA) ( const SparseWA* swa, 0074 /*OUT*/UWord* valP, 0075 UWord key ); 0076 0077 // Set up 'swa' for iteration. 0078 void VG_(initIterSWA) ( SparseWA* swa ); 0079 0080 // Get the next key/val pair. Behaviour undefined (highly likely 0081 // to segfault) if 'swa' has been modified since initIterSWA was 0082 // called. Returned Bool is False iff there are no more pairs 0083 // that can be extracted. 0084 Bool VG_(nextIterSWA)( SparseWA* swa, 0085 /*OUT*/UWord* keyP, /*OUT*/UWord* valP ); 0086 0087 // How many elements are there in 'swa'? NOTE: dangerous in the 0088 // sense that this is not an O(1) operation but rather O(N), 0089 // since it involves walking the whole tree. 0090 UWord VG_(sizeSWA) ( const SparseWA* swa ); 0091 0092 #endif // __PUB_TOOL_SPARSEWA_H 0093 0094 /*--------------------------------------------------------------------*/ 0095 /*--- end pub_tool_sparsewa.h ---*/ 0096 /*--------------------------------------------------------------------*/
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |