Index: src/linkedcell.cpp
===================================================================
--- src/linkedcell.cpp	(revision e1bc6830af4c7501528091f383832e414f3c59e4)
+++ src/linkedcell.cpp	(revision e1bc6830af4c7501528091f383832e414f3c59e4)
@@ -0,0 +1,163 @@
+#include "linkedcell.hpp"
+#include "molecules.hpp"
+
+/** Constructor for class LinkedCell.
+ */
+LinkedCell::LinkedCell()
+{
+  LC = NULL;
+  for(int i=0;i<NDIM;i++)
+    N[i] = 0;
+  index = -1;
+  RADIUS = 0.;
+  max.Zero();
+  min.Zero();
+};
+
+/** Puts all atoms in \a *mol into a linked cell list with cell's lengths of \a RADIUS
+ * \param *mol molecule structure with all Atom's
+ * \param RADIUS edge length of cells
+ */
+LinkedCell::LinkedCell(molecule *mol, double radius)
+{
+  atom *Walker = NULL;
+
+  RADIUS = radius;
+  LC = NULL;
+  for(int i=0;i<NDIM;i++)
+    N[i] = 0;
+  index = -1;
+  max.Zero();
+  min.Zero();
+  cout << Verbose(1) << "Begin of LinkedCell" << endl;
+  if (mol->start->next == mol->end) {
+    cerr << "ERROR: molecule contains no atoms!" << endl;
+    return;
+  }
+  // 1. find max and min per axis of atoms
+  Walker = mol->start->next;
+  for (int i=0;i<NDIM;i++) {
+    max.x[i] = Walker->x.x[i];
+    min.x[i] = Walker->x.x[i];
+  }
+  while (Walker != mol->end) {
+    for (int i=0;i<NDIM;i++) {
+      if (max.x[i] < Walker->x.x[i])
+        max.x[i] = Walker->x.x[i];
+      if (min.x[i] > Walker->x.x[i])
+        min.x[i] = Walker->x.x[i];
+    }
+    Walker = Walker->next;
+  }
+  cout << Verbose(2) << "Bounding box is " << min << " and " << max << "." << endl;
+  
+  // 2. find then umber of cells per axis
+  for (int i=0;i<NDIM;i++) {
+    N[i] = (int)floor((max.x[i] - min.x[i])/RADIUS)+1;
+  }
+  cout << Verbose(2) << "Number of cells per axis are " << N[0] << ", " << N[1] << " and " << N[2] << "." << endl;
+  
+  // 3. allocate the lists  
+  cout << Verbose(2) << "Allocating cells ... " << endl;
+  if (LC != NULL) {
+    cout << Verbose(1) << "ERROR: Linked Cell list is already allocated, I do nothing." << endl;
+    return;
+  }
+  LC = new LinkedAtoms[N[0]*N[1]*N[2]]; 
+  for (index=0;index<N[0]*N[1]*N[2];index++) {
+    LC [index].clear(); 
+  }
+  
+  // 4. put each atom into its respective cell 
+  Walker = mol->start;
+  while (Walker->next != mol->end) {
+    Walker = Walker->next;
+    for (int i=0;i<NDIM;i++) {
+      n[i] = (int)floor((Walker->x.x[i] - min.x[i])/RADIUS);
+    }
+    index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
+    LC[index].push_back(Walker);
+    cout << Verbose(2) << *Walker << " goes into cell " << n[0] << ", " << n[1] << ", " << n[2] << " with No. " << index << "." << endl;
+  }
+  cout << Verbose(1) << "End of LinkedCell" << endl;
+};
+
+/** Destructor for class LinkedCell.
+ */
+LinkedCell::~LinkedCell()
+{
+  if (LC != NULL)
+    for (index=0;index<N[0]*N[1]*N[2];index++)
+      LC[index].clear();
+  delete[](LC);
+  for(int i=0;i<NDIM;i++)
+    N[i] = 0;
+  index = -1;
+  max.Zero();
+  min.Zero();
+};
+
+/** Checks whether LinkedCell::n[] is each within [0,N[]].
+ * \return if all in intervals - true, else -false
+ */
+bool LinkedCell::CheckBounds()
+{
+  bool status = true;
+  for(int i=0;i<NDIM;i++)
+    status = status && ((n[i] >=0) && (n[i] < N[i]));
+  if (!status)
+    cerr << "ERROR: indices are out of bounds!" << endl;
+  return status;
+};
+
+
+/** Returns a pointer to the current cell.
+ * \return LinkedAtoms pointer to current cell, NULL if LinkedCell::n[] are out of bounds.
+ */
+LinkedAtoms* LinkedCell::GetCurrentCell()
+{
+  if (CheckBounds()) {
+    index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
+    return (&(LC[index]));
+  } else {
+    return NULL;
+  }
+};
+
+/** Calculates the index for a given atom *Walker.
+ * \param *Walker atom to set index to
+ * \return if the atom is also found in this cell - true, else - false
+ */
+bool LinkedCell::SetIndexToAtom(atom *Walker)
+{
+  bool status = false;
+  for (int i=0;i<NDIM;i++) {
+    n[i] = (int)floor((Walker->x.x[i] - min.x[i])/RADIUS);
+  }
+  index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
+  if (CheckBounds()) {
+    for (LinkedAtoms::iterator Runner = LC[index].begin(); Runner != LC[index].end(); Runner++)
+      status = status || ((*Runner) == Walker);
+    return status;
+  } else {
+    cerr << Verbose(1) << "ERROR: Atom "<< *Walker << " at " << Walker->x << " is out of bounds." << endl;
+    return false;
+  }
+};
+
+/** Calculates the index for a given Vector *x.
+ * \param *x Vector with coordinates
+ * \return Vector is inside bounding box - true, else - false
+ */
+bool LinkedCell::SetIndexToVector(Vector *x)
+{
+  bool status = true;
+  for (int i=0;i<NDIM;i++) {
+    n[i] = (int)floor((x->x[i] - min.x[i])/RADIUS);
+    if (max.x[i] < x->x[i])
+      status = false;
+    if (min.x[i] > x->x[i])
+      status = false;
+  }
+  return status;
+};
Index: src/linkedcell.hpp
===================================================================
--- src/linkedcell.hpp	(revision e1bc6830af4c7501528091f383832e414f3c59e4)
+++ src/linkedcell.hpp	(revision e1bc6830af4c7501528091f383832e414f3c59e4)
@@ -0,0 +1,30 @@
+#ifndef LINKEDCELL_HPP_
+#define LINKEDCELL_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "molecules.hpp"
+
+class LinkedCell{
+  public:
+    Vector max;       // upper boundary
+    Vector min;       // lower boundary
+    LinkedAtoms *LC;  // linked cell list
+    double RADIUS;    // cell edge length
+    int N[NDIM];      // number of cells per axis
+    int n[NDIM];      // temporary variable for current cell per axis
+    int index;        // temporary index variable , access by index = n[0] * N[1] * N[2] + n[1] * N[2] + n[2];
+    
+    LinkedCell();
+    LinkedCell(molecule *mol, double RADIUS);
+    ~LinkedCell();
+    LinkedAtoms* GetCurrentCell();
+    bool SetIndexToAtom(atom *Walker);
+    bool SetIndexToVector(Vector *x);
+    bool CheckBounds();
+};
+
+#endif /*LINKEDCELL_HPP_*/
