class ProjectedDatabase {

	public TreeSet<FrequentSequenceItem> getLocallyFrequentItems(Set<FrequentSequenceItem> globallyFrequentItems,
			int minSupport) {
		Map<SequenceItem, Integer> frequentItemBag = new HashMap<SequenceItem, Integer>();
		for (ProjectedSequenceInfo currentProjSeq : projectedInfo) {
			for (FrequentSequenceItem globFreqItem : globallyFrequentItems) {
				SequenceItem globalItem = globFreqItem.getItem();
				int index = globalItem.getIndex();
				if (index < currentProjSeq.getProjectedIndex()) {
					continue;//the globally frequent item is in a position in the prefix, no need to check
				}
				Sequence fullSequence =
					database.getSequences().get(currentProjSeq.getSequenceIndex());
				String symbol = fullSequence.getSequenceAsString().substring(index, index + 1);

				if (!symbol.equals(globalItem.getSymbol())) {
					continue;//symbols are different, check next item
				}

				Integer count = frequentItemBag.get(globalItem);
				if (count == null) {
					frequentItemBag.put(globalItem, new Integer(fullSequence.getCount()));
				}
				else {
					frequentItemBag.put(globalItem, count + fullSequence.getCount());
				}
			}
		}

		TreeSet<FrequentSequenceItem> frequentItemSet = new TreeSet<FrequentSequenceItem>();
		for (Entry<SequenceItem, Integer> itemAndCount : frequentItemBag.entrySet()) {
			int count = itemAndCount.getValue();
			if (count >= minSupport) {
				frequentItemSet.add(new FrequentSequenceItem(count, itemAndCount.getKey()));
			}
		}
		return frequentItemSet;
	}

	public  ProjectedDatabase(SequenceDatabase database, List<SequenceItem> prefixSequence);
	public  ProjectedDatabase(ProjectedDatabase projDatabase, SequenceItem extendingItem);

}