<commit_before>/* dftbx
 * 
 * DIALS Framework Toolbox:
 * 
 * Framework code (i.e. not model, not algorithm, not interface) code for DIALS
 * which currently contains:
 *
 * ObservationList template class
 * ReflectionList template class
 * 
 */

#ifndef DFTBX_DFTBX_H
#define DFTBX_DFTBX_H

#include <boost/python.hpp>
#include <scitbx/array_family/shared.h>
#include <scitbx/array_family/flex_types.h>
#include <miller.h>
#include <uctbx.h>
#include <cctype>
#include <map>
#include <algorithm>

namespace dftbx {

  void init_module() { };

  /** miller_index_t 
   *
   * Typedef'd to be integer Miller indices: DIALS won't be using other types.
   */
 
  typedef cctbx::miller::index<int> miller_index_t;

  /** ObservationList<T>
   * 
   * If T is big the caller should be responsible for making T a shared pointer
   * and handling issues with duplicate pointers possibly modifying T's 
   * elsewhere. If T is small no worries, but the merge() method below will 

   *
   */
 
  template <class T> 
    class ObservationList {
  public:

    typedef typename scitbx::af::shared<T> vector_type;

    size_t size() const {
      return observations_.size();
    }

    void push_back(const T & t) {
      observations_.push_back(t);
    }

    void clear() {
      observations_.clear();
    }

    T & operator[](size_t j) {
      return observations_[j];
    }

    const T & operator[](size_t j) const {
      return observations_[j];
    }

    void duplicate(const ObservationList<T> & other) {
      for (size_t j = 0; j < other.size(); j ++) {
	observations_.push_back(other[j]);
      }
    }

    void merge(ObservationList<T> & other) {
      for (size_t j = 0; j < other.size(); j ++) {
	observations_.push_back(other[j]);
      }
      other.clear();
    }

  private:

    vector_type observations_;

  };

  template <class T>
    class ReflectionList {
  public:

    typedef ObservationList<T> observation_list_type;

    typedef std::map<miller_index_t, observation_list_type> map_type;
    typedef typename map_type::iterator map_iterator_type;

    T & operator[](miller_index_t hkl) {
      return reflections_[hkl];
    }

    const T & operator[](miller_index_t hkl) const {
      return reflections_[hkl];
    }

    void merge(ReflectionList<T> & other) {
      map_iterator_type ri;
      for (ri = reflections_.begin(); ri != reflections_.end(); ++ri) {
	ri->second.merge(other[ri->first]);
      }
    }
    
  private:
    map_type reflections_;
      
  };
  
  typedef ObservationList<int> int_ol;
  typedef ReflectionList<int> int_rl;


}

#endif<commit_msg>Removed operator[] stuff but now have it compiling...<commit_after>/* dftbx
 * 
 * DIALS Framework Toolbox:
 * 
 * Framework code (i.e. not model, not algorithm, not interface) code for DIALS
 * which currently contains:
 *
 * ObservationList template class
 * ReflectionList template class
 * 
 */

#ifndef DFTBX_DFTBX_H
#define DFTBX_DFTBX_H

#include <boost/python.hpp>
#include <scitbx/array_family/shared.h>
#include <scitbx/array_family/flex_types.h>
#include <miller.h>
#include <uctbx.h>
#include <cctype>
#include <map>
#include <algorithm>

namespace dftbx {

  void init_module() { };

  /** miller_index_t 
   *
   * Typedef'd to be integer Miller indices: DIALS won't be using other types.
   */
 
  typedef cctbx::miller::index<int> miller_index_t;

  /** ObservationList<T>
   * 
   * If T is big the caller should be responsible for making T a shared pointer
   * and handling issues with duplicate pointers possibly modifying T's 
   * elsewhere. If T is small no worries, but the merge() method below will 

   *
   */
 
  template <class T> 
    class ObservationList {
  public:

    typedef typename scitbx::af::shared<T> vector_type;

    size_t size() const {
      return observations_.size();
    }

    void push_back(const T & t) {
      observations_.push_back(t);
    }

    void clear() {
      observations_.clear();
    }

    T & operator[](size_t j) {
      return observations_[j];
    }

    const T & operator[](size_t j) const {
      return observations_[j];
    }

    void duplicate(const ObservationList<T> & other) {
      for (size_t j = 0; j < other.size(); j ++) {
	observations_.push_back(other[j]);
      }
    }

    void merge(ObservationList<T> & other) {
      for (size_t j = 0; j < other.size(); j ++) {
	observations_.push_back(other[j]);
      }
      other.clear();
    }

  private:

    vector_type observations_;

  };

  template <class T>
    class ReflectionList {
  public:

    typedef ObservationList<T> observation_list_t;

    typedef std::map<miller_index_t, observation_list_t> map_type;
    typedef typename map_type::iterator map_iterator_type;

    observation_list_t & operator[](miller_index_t hkl) {
      return reflections_[hkl];
    }

    const observation_list_t & operator[](miller_index_t hkl) const {
      return reflections_[hkl];
    }

    void merge(ReflectionList<T> & other) {
      map_iterator_type mi;
      for (mi = reflections_.begin(); mi != reflections_.end(); ++mi) {
	mi->second.merge(other[mi->first]);
      }
    }
    
  private:
    map_type reflections_;
      
  };
  
  typedef ObservationList<int> int_ol;
  typedef ReflectionList<int> int_rl;


}

#endif
{'fraction_non_alphanumeric': 0.11497529456480425, 'fraction_numerical': 0.0007601672367920942, 'mean_word_length': 3.0515781370284834, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7113933', 'n_tokens_mistral': 1834, 'n_tokens_neox': 1715, 'n_words': 440}