blob: 1c6ba139688e77808e1a4ab5a8c88be6cc35bbde [file] [log] [blame]
Mathieu Chartierfc8b4222017-09-17 13:44:24 -07001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
David Sehr334b9d72018-02-12 18:27:56 -080017#ifndef ART_LIBDEXFILE_DEX_DEX_FILE_REFERENCE_H_
18#define ART_LIBDEXFILE_DEX_DEX_FILE_REFERENCE_H_
Mathieu Chartierfc8b4222017-09-17 13:44:24 -070019
20#include <cstdint>
21
22namespace art {
23
24class DexFile;
25
26class DexFileReference {
27 public:
28 DexFileReference(const DexFile* file, uint32_t idx) : dex_file(file), index(idx) {}
29 const DexFile* dex_file;
30 uint32_t index;
31
32 struct Comparator {
33 bool operator()(const DexFileReference& a, const DexFileReference& b) const {
34 if (a.dex_file != b.dex_file) {
35 return a.dex_file < b.dex_file;
36 }
37 return a.index < b.index;
38 }
39 };
40};
41
Alex Light1e52a072019-06-25 09:12:04 -070042// Default comparators, compares the indices, not the backing data.
Mathieu Chartierfc8b4222017-09-17 13:44:24 -070043inline bool operator<(const DexFileReference& a, const DexFileReference& b) {
44 return DexFileReference::Comparator()(a, b);
45}
46inline bool operator==(const DexFileReference& a, const DexFileReference& b) {
47 return a.dex_file == b.dex_file && a.index == b.index;
48}
49
50} // namespace art
51
David Sehr334b9d72018-02-12 18:27:56 -080052#endif // ART_LIBDEXFILE_DEX_DEX_FILE_REFERENCE_H_