Example usage for java.util TreeSet remove

List of usage examples for java.util TreeSet remove

Introduction

In this page you can find the example usage for java.util TreeSet remove.

Prototype

public boolean remove(Object o) 

Source Link

Document

Removes the specified element from this set if it is present.

Usage

From source file:org.apache.phoenix.mapreduce.MultiHfileOutputFormat.java

private static void writePartitions(Configuration conf, Path partitionsPath,
        Set<CsvTableRowkeyPair> tablesStartKeys) throws IOException {

    LOG.info("Writing partition information to " + partitionsPath);
    if (tablesStartKeys.isEmpty()) {
        throw new IllegalArgumentException("No regions passed");
    }//from w ww. j a v a 2  s . c  o m

    // We're generating a list of split points, and we don't ever
    // have keys < the first region (which has an empty start key)
    // so we need to remove it. Otherwise we would end up with an
    // empty reducer with index 0
    TreeSet<CsvTableRowkeyPair> sorted = new TreeSet<CsvTableRowkeyPair>(tablesStartKeys);

    CsvTableRowkeyPair first = sorted.first();
    if (!first.getRowkey().equals(HConstants.EMPTY_BYTE_ARRAY)) {
        throw new IllegalArgumentException("First region of table should have empty start key. Instead has: "
                + Bytes.toStringBinary(first.getRowkey().get()));
    }
    sorted.remove(first);

    // Write the actual file
    FileSystem fs = partitionsPath.getFileSystem(conf);
    SequenceFile.Writer writer = SequenceFile.createWriter(fs, conf, partitionsPath, CsvTableRowkeyPair.class,
            NullWritable.class);

    try {
        for (CsvTableRowkeyPair startKey : sorted) {
            writer.append(startKey, NullWritable.get());
        }
    } finally {
        writer.close();
    }

}

From source file:com.ailk.oci.ocnosql.tools.load.single.SingleColumnImportTsv.java

/**
 * Write out a SequenceFile that can be read by TotalOrderPartitioner
 * that contains the split points in startKeys.
 * @param partitionsPath output path for SequenceFile
 * @param startKeys the region start keys
 */// w ww .  java 2 s .  c  o m
private static void writePartitions(Configuration conf, Path partitionsPath,
        List<ImmutableBytesWritable> startKeys) throws IOException {
    if (startKeys.isEmpty()) {
        throw new IllegalArgumentException("No regions passed");
    }

    // We're generating a list of split points, and we don't ever
    // have keys < the first region (which has an empty start key)
    // so we need to remove it. Otherwise we would end up with an
    // empty reducer with index 0
    TreeSet<ImmutableBytesWritable> sorted = new TreeSet<ImmutableBytesWritable>(startKeys);

    ImmutableBytesWritable first = sorted.first();
    if (!first.equals(HConstants.EMPTY_BYTE_ARRAY)) {
        throw new IllegalArgumentException("First region of table should have empty start key. Instead has: "
                + Bytes.toStringBinary(first.get()));
    }
    sorted.remove(first);

    // Write the actual file
    FileSystem fs = partitionsPath.getFileSystem(conf);
    SequenceFile.Writer writer = SequenceFile.createWriter(fs, conf, partitionsPath,
            ImmutableBytesWritable.class, NullWritable.class);

    try {
        for (ImmutableBytesWritable startKey : sorted) {
            writer.append(startKey, NullWritable.get());
        }
    } finally {
        writer.close();
    }
}

From source file:turtlekit.viewer.PopulationCharter.java

/**
 * @return/*from w  w  w  .  j  a  va  2 s .  c  o m*/
 */
private TreeSet<String> getExistingRoles() {
    TreeSet<String> roles = getExistingRoles(getCommunity(), TKOrganization.TURTLES_GROUP);
    if (roles != null) {
        roles.remove(Organization.GROUP_MANAGER_ROLE);
        if (!monitorTurtle) {
            roles.remove(TKOrganization.TURTLE_ROLE);
        }
    }
    return roles;
}

From source file:com.cyanogenmod.eleven.utils.SongPopupMenuHelper.java

@Override
protected void updateMenuIds(PopupMenuType type, TreeSet<Integer> set) {
    super.updateMenuIds(type, set);

    // Don't show more by artist if it is an unknown artist
    if (MediaStore.UNKNOWN_STRING.equals(mSong.mArtistName)) {
        set.remove(FragmentMenuItems.MORE_BY_ARTIST);
    }/*from   ww w  .j  a v  a  2  s  .co m*/
}

From source file:com.cyanogenmod.eleven.utils.AlbumPopupMenuHelper.java

@Override
protected void updateMenuIds(PopupMenuType type, TreeSet<Integer> set) {
    super.updateMenuIds(type, set);

    // Don't show more by artist if it is an unknown artist
    if (MediaStore.UNKNOWN_STRING.equals(mAlbum.mArtistName)) {
        set.remove(FragmentMenuItems.MORE_BY_ARTIST);
    }/*from w ww .  j a va 2  s  .co  m*/
}

From source file:org.jamocha.dn.ConflictSet.java

public synchronized boolean remove(final RuleAndToken ruleAndToken) {
    final Integer salience = ruleAndToken.rule.getParent().getSalience();
    final TreeSet<RuleAndToken> ratSet = this.rulesAndTokensBySalience.get(salience);
    if (null == ratSet)
        return false;
    final boolean removed = ratSet.remove(ruleAndToken);
    if (ratSet.isEmpty()) {
        this.rulesAndTokensBySalience.remove(salience);
    }//from  w ww .  j av  a 2 s. c  om
    return removed;
}

From source file:org.apache.asterix.common.config.ConfigUsageTest.java

protected Set<Section> getSections(ConfigManager configManager) {
    TreeSet<Section> sections = new TreeSet<>(Comparator.comparing(Section::sectionName));
    sections.addAll(configManager.getSections());
    sections.remove(Section.LOCALNC);
    return sections;
}

From source file:com.cyanogenmod.eleven.ui.fragments.ArtistDetailFragment.java

private void setupPopupMenuHelpers() {
    mSongPopupMenuHelper = new SongPopupMenuHelper(getActivity(), getChildFragmentManager()) {
        @Override//from www.j  av a  2s  .c om
        public Song getSong(int position) {
            return mSongAdapter.getItem(position);
        }

        @Override
        protected long getSourceId() {
            return getArtistId();
        }

        @Override
        protected Config.IdType getSourceType() {
            return Config.IdType.Artist;
        }

        @Override
        protected void updateMenuIds(PopupMenuType type, TreeSet<Integer> set) {
            super.updateMenuIds(type, set);

            // since we are already on the artist page, this item doesn't make sense
            set.remove(FragmentMenuItems.MORE_BY_ARTIST);
        }
    };

    mAlbumPopupMenuHelper = new AlbumPopupMenuHelper(getActivity(), getChildFragmentManager()) {
        @Override
        public Album getAlbum(int position) {
            return mAlbumAdapter.getItem(position);
        }

        @Override
        protected void updateMenuIds(PopupMenuType type, TreeSet<Integer> set) {
            super.updateMenuIds(type, set);

            // since we are already on the artist page, this item doesn't make sense
            set.remove(FragmentMenuItems.MORE_BY_ARTIST);
        }
    };
}

From source file:com.cyanogenmod.eleven.ui.fragments.PlaylistDetailFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mPopupMenuHelper = new SongPopupMenuHelper(getActivity(), getFragmentManager()) {
        @Override//w  w w  .  j a va  2 s . c  o m
        public Song getSong(int position) {
            if (position == 0) {
                return null;
            }

            return mAdapter.getItem(position);
        }

        @Override
        protected void updateMenuIds(PopupMenuType type, TreeSet<Integer> set) {
            super.updateMenuIds(type, set);

            set.add(FragmentMenuItems.REMOVE_FROM_PLAYLIST);
            set.remove(FragmentMenuItems.DELETE);
        }

        @Override
        protected long getSourceId() {
            return mPlaylistId;
        }

        @Override
        protected Config.IdType getSourceType() {
            return Config.IdType.Playlist;
        }

        @Override
        protected void removeFromPlaylist() {
            mAdapter.remove(mSong);
            mAdapter.buildCache();
            mAdapter.notifyDataSetChanged();
            MusicUtils.removeFromPlaylist(getActivity(), mSong.mSongId, mPlaylistId);
            getLoaderManager().restartLoader(LOADER, null, PlaylistDetailFragment.this);
        }
    };

    mPlaylistId = getArguments().getLong(Config.ID);
    lookupName();
}

From source file:org.fusesource.mop.support.Database.java

public TreeSet<String> listDependenants(final String artifact) throws IOException {
    assertOpen();// www  . j a v  a  2  s. co m
    return pageFile.tx().execute(new Transaction.CallableClosure<TreeSet<String>, IOException>() {
        public TreeSet<String> execute(Transaction tx) throws IOException {
            RootEntity root = RootEntity.load(tx);
            BTreeIndex<String, HashSet<String>> artifacts = root.artifacts.get(tx);
            HashSet<String> deps = artifacts.get(tx, artifact);
            if (deps == null) {
                return null;
            }
            TreeSet<String> rc = new TreeSet<String>();

            rc.addAll(deps);
            rc.remove(artifact);
            return rc;
        }
    });
}