tikhomirov@433: /* tikhomirov@433: * Copyright (c) 2011-2012 TMate Software Ltd tikhomirov@433: * tikhomirov@433: * This program is free software; you can redistribute it and/or modify tikhomirov@433: * it under the terms of the GNU General Public License as published by tikhomirov@433: * the Free Software Foundation; version 2 of the License. tikhomirov@433: * tikhomirov@433: * This program is distributed in the hope that it will be useful, tikhomirov@433: * but WITHOUT ANY WARRANTY; without even the implied warranty of tikhomirov@433: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the tikhomirov@433: * GNU General Public License for more details. tikhomirov@433: * tikhomirov@433: * For information on how to redistribute this software under tikhomirov@433: * the terms of a license other than GNU General Public License tikhomirov@433: * contact TMate Software at support@hg4j.com tikhomirov@433: */ tikhomirov@433: package org.tmatesoft.hg.repo; tikhomirov@433: tikhomirov@433: import static org.tmatesoft.hg.repo.HgRepository.BAD_REVISION; tikhomirov@433: import static org.tmatesoft.hg.repo.HgRepository.TIP; tikhomirov@433: tikhomirov@433: import org.tmatesoft.hg.core.Nodeid; tikhomirov@433: import org.tmatesoft.hg.internal.ArrayHelper; tikhomirov@433: import org.tmatesoft.hg.repo.Revlog.RevisionInspector; tikhomirov@433: tikhomirov@433: /** tikhomirov@433: * Effective int to Nodeid and vice versa translation. It's advised to use this class instead of tikhomirov@433: * multiple {@link Revlog#getRevisionIndex(Nodeid)} calls. Rule of thumb is 20+ calls (given tikhomirov@433: * initialization costs). It's also important to take into account memory consumption, for huge tikhomirov@433: * repositories use of this class may pay off only when accessing greatest fraction of all revisions. tikhomirov@433: * tikhomirov@433: *
Next code snippet shows instantiation and sample use: tikhomirov@433: *
tikhomirov@433: * RevisionMaptikhomirov@433: * tikhomirov@433: *clogMap = new RevisionMap (clog).init(); tikhomirov@433: * RevisionMap fileMap = new RevisionMap (fileNode).init(); tikhomirov@433: * tikhomirov@433: * int fileRevIndex = 0; tikhomirov@433: * Nodeid fileRev = fileMap.revision(fileRevIndex); tikhomirov@433: * int csetRevIndex = fileNode.getChangesetRevisionIndex(fileRevIndex); tikhomirov@433: * Nodeid csetRev = clogMap.revision(localCset); tikhomirov@433: * changesetToNodeidMap.put(csetRev, fileRev); tikhomirov@433: *
tikhomirov@433: * {@link Revlog#getRevisionIndex(Nodeid)} with straightforward lookup approach performs O(n/2) tikhomirov@433: *
tikhomirov@433: * {@link HgRevisionMap#revisionIndex(Nodeid)} is log(n), plus initialization is O(n) (just once).
tikhomirov@433: *
tikhomirov@433: * @see HgParentChildMap
tikhomirov@433: *
tikhomirov@433: * @author Artem Tikhomirov
tikhomirov@433: * @author TMate Software Ltd.
tikhomirov@433: */
tikhomirov@433: public final class HgRevisionMapthis
for convenience.
tikhomirov@433: */
tikhomirov@628: public HgRevisionMap