FlashGraph-ng
A new frontier in large-scale graph analysis and data mining
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
crs_header.h
1 #ifndef __CRS_HEADER_H__
2 #define __CRS_HEADER_H__
3 
4 /*
5  * Copyright 2014 Open Connectome Project (http://openconnecto.me)
6  * Written by Da Zheng (zhengda1936@gmail.com)
7  *
8  * This file is part of FlashMatrix.
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  */
22 
23 #include <stdlib.h>
24 
25 class crs_header
26 {
27  union {
28  char page[4096];
29  struct {
30  size_t nrows;
31  size_t ncols;
32  size_t nnz;
33  } s;
34  } data;
35 public:
36  crs_header() {
37  memset(this, 0, sizeof(*this));
38  }
39 
40  crs_header(size_t nrows, size_t ncols, size_t nnz) {
41  data.s.nrows = nrows;
42  data.s.ncols = ncols;
43  data.s.nnz = nnz;
44  }
45 
46  size_t get_num_rows() const {
47  return data.s.nrows;
48  }
49 
50  size_t get_num_cols() const {
51  return data.s.ncols;
52  }
53 
54  size_t get_num_non_zeros() const {
55  return data.s.nnz;
56  }
57 };
58 
59 typedef size_t crs_idx_t;
60 
61 #endif