File: AtomNeighbors.h

package info (click to toggle)
pymol 2.5.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 42,288 kB
  • sloc: cpp: 476,472; python: 76,538; ansic: 29,510; javascript: 6,792; sh: 47; makefile: 24
file content (38 lines) | stat: -rw-r--r-- 820 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
 * (c) Schrodinger, Inc.
 */

#pragma once

struct ObjectMolecule;

/**
 * Proxy for ObjectMolecule::Neighbor entries of a given atom.
 */
class AtomNeighbors
{
  const int* m_neighbor;

public:
  struct value_type {
    // Member layout must match ObjectMolecule::Neighbor.
    // The data layout is described in ObjectMolecule::getNeighborArray.
    int atm;  ///< Atom index
    int bond; ///< Bond index
  };

  AtomNeighbors(const ObjectMolecule* I, int atm);

  /// Get the i'th neighbor
  const value_type& operator[](size_t i) const { return *(begin() + i); }

  /// Number of neighbors
  unsigned size() const { return m_neighbor[0]; }

  const value_type* begin() const
  {
    return reinterpret_cast<value_type const*>(m_neighbor + 1);
  }

  const value_type* end() const { return begin() + size(); }
};