code: private static int[] indexElements(Map<IAtom, Integer> map, IStereoElement[] elements, Type[] types,
              IAtomContainer container) {
          int[] indices = new int[container.getAtomCount()];
          int nElements = 0;
          for (IStereoElement element : container.stereoElements()) {
              if (element instanceof ITetrahedralChirality) {
                  ITetrahedralChirality tc = (ITetrahedralChirality) element;
                  int idx = map.get(tc.getChiralAtom());
                  elements[idx] = element;
                  types[idx] = Type.Tetrahedral;
                  indices[nElements++] = idx;
              } else if (element instanceof IDoubleBondStereochemistry) {
                  IDoubleBondStereochemistry dbs = (IDoubleBondStereochemistry) element;
                  int idx1 = map.get(dbs.getStereoBond().getBegin());
                  int idx2 = map.get(dbs.getStereoBond().getEnd());
                  elements[idx2] = elements[idx1] = element;
                  types[idx1] = types[idx2] = Type.Geometric;
                  indices[nElements++] = idx1; // only visit the first atom
              }
          }
          return Arrays.copyOf(indices, nElements);
      }
docs: Index the stereo elements of the {@code container} into the the {@code
  elements} and {@code types} arrays. The {@code map} is used for looking
  up the index of atoms.
  
  @param map       index of atoms
  @param elements  array to fill with stereo elements
  @param types     type of stereo element indexed
  @param container the container to index the elements of
  @return indices of atoms involved in stereo configurations