Remove duplications and successors for presented topics in array.

@param topics array to be processed
@return resulted array
@since 1.3.1
341892
@Nonnull
  @MustNotContainNull
  public static Topic[] removeSuccessorsAndDuplications(@Nonnull @MustNotContainNull final Topic... topics) {
    final List<Topic> result = new ArrayList<Topic>();

    for (final Topic t : topics) {
      final Iterator<Topic> iterator = result.iterator();
      while (iterator.hasNext()) {
        final Topic listed = iterator.next();
        if (listed == t || listed.hasAncestor(t)) {
          iterator.remove();
        }
      }
      result.add(t);
    }
    return result.toArray(new Topic[result.size()]);
  }
676035
def set_topics(self, topics):
        
        if set(topics).difference(self._topics):
            future = self.cluster.request_update()
        else:
            future = Future().success(set(topics))
        self._topics = set(topics)
        return future
487616
public static INDArray[] dup(INDArray[] history) {
        INDArray[] dupHistory = new INDArray[history.length];
        for (int i = 0; i < history.length; i++) {
            dupHistory[i] = history[i].dup();
        }
        return dupHistory;
    }
518283
public void removeDuplicateFilters(JMessageListener listenerToCheck)
    {
        for (int iIndex = 0; ; iIndex++)
        {
            BaseMessageFilter filter = listenerToCheck.getListenerMessageFilter(iIndex);
            if (filter == null)
                break;
            if (this.isSameFilter(filter))
            {
                if (filter.getMessageListener(1) == null)
                {   // Only free if the message list is the same and only
                    filter.removeFilterMessageListener(listenerToCheck);
                // DO NOT free the listener.
                    filter.free();     // Cool, it was a dup... get rid of it.
                    iIndex--;
                }
            }
        }
    }
995298
def clear_offsets_excluding(excluded)
      # Clear all offsets that aren't in `excluded`.
      @processed_offsets.each do |topic, partitions|
        partitions.keep_if do |partition, _|
          excluded.fetch(topic, []).include?(partition)
        end
      end

      # Clear the cached commits from the brokers.
      @committed_offsets = nil
      @resolved_offsets.clear
    end
241513
public List<TopicRelationship> getPrevTopicRelationships() {
        ArrayList<TopicRelationship> relationships = new ArrayList<TopicRelationship>();
        for (TopicRelationship relationship : topicRelationships) {
            if (relationship.getType() == RelationshipType.PREVIOUS) {
                relationships.add(relationship);
            }
        }
        for (TargetRelationship relationship : topicTargetRelationships) {
            if (relationship.getType() == RelationshipType.PREVIOUS) {
                relationships.add(new TopicRelationship(relationship.getPrimaryRelationship(), (SpecTopic) relationship.getSecondaryRelationship(),
                        relationship.getType()));
            }
        }
        return relationships;
    }
1298761
public void removeSubscriptions() {
        for (TopicSubscriber subscriber : subscribers.values()) {
            try {
                subscriber.close();
            } catch (Throwable e) {
                log.debug("Error closing subscriber", e);//is level appropriate - previously hidden exception -afranken
            }
        }
        
        subscribers.clear();
    }
1163997
public static int removeDuplicateNodeList(List<String> list) {

        int originCount = list.size();
        // add elements to all, including duplicates
        HashSet<String> hs = new LinkedHashSet<String>();
        hs.addAll(list);
        list.clear();
        list.addAll(hs);

        return originCount - list.size();
    }
520649
protected void removeSubscription(SIBUuid12 topicSpace,
                                    String topic)
  {
    // Generate a key for the topicSpace/topic
    final String key = BusGroup.subscriptionKey(topicSpace, topic);

    iProxies.remove(key);
  }
692202
def remove_topic(self, topic_id):
        
        comment_start = 0
        while comment_start is not None:
            comments = self.list_comments(topic_id, comment_start)
            for comment in comments['results']:
                self.remove_comment(topic_id, comment['id'])
            comment_start = comments['next_start']
        return self.api.req(API_GROUP_REMOVE_TOPIC % topic_id, params={'ck': self.api.ck()})
25313
public void setDatabaseDuplicateIds() {
        // Set the spec topic duplicate ids based on topic title
        for (final Entry<Integer, List<ITopicNode>> topicTitleEntry : topics.entrySet()) {
            final List<ITopicNode> topics = topicTitleEntry.getValue();
            if (topics.size() > 1) {
                for (int i = 1; i < topics.size(); i++) {
                    topics.get(i).setDuplicateId(Integer.toString(i));
                }
            }
        }
    }
1121588
function(topicArray) {
    // start at the end, replace each
    // + w/ a # recursively until no other filter...
    var optimized = [];
    topicArray.forEach(function(filterString) {
      optimized.push(filterString.replace(/(\/\+)+$/g,'\/#'));
    });
    return optimized;
  }
104540
public Collection<TopicPartition> getTopicPartitions() {
        Collection<TopicPartitionGroup> topicPartitions = getTopicPartitionGroups();
        Set<TopicPartition> tps = new HashSet<TopicPartition>();
        if (topicPartitions != null) {
            for (TopicPartitionGroup g : topicPartitions) {
                tps.addAll(g.getTopicPartitions());
            }
        }
        return tps;
    }
1313682
public List<ITopicNode> getAllTopicNodes() {
        final ArrayList<ITopicNode> topicNodes = new ArrayList<ITopicNode>();
        for (final Entry<Integer, List<ITopicNode>> topicEntry : topics.entrySet()) {
            topicNodes.addAll(topicEntry.getValue());
        }

        return topicNodes;
    }
101336
public synchronized List<String> getTopicList() {
    final List<String> res = new ArrayList<>(this.topicEventMap.keySet());
    return res;
  }
1053640
private function getDuplicates(): array
  {
    // First pass make lookup table by method_name.
    $lookup = [];
    foreach ($this->sources as $source)
    {
      if (isset($source['method_name']))
      {
        if (!isset($lookup[$source['method_name']]))
        {
          $lookup[$source['method_name']] = [];
        }

        $lookup[$source['method_name']][] = $source;
      }
    }

    // Second pass find duplicate sources.
    $duplicates_sources = [];
    $duplicates_methods = [];
    foreach ($this->sources as $source)
    {
      if (sizeof($lookup[$source['method_name']])>1)
      {
        $duplicates_sources[$source['path_name']]   = $source;
        $duplicates_methods[$source['method_name']] = $lookup[$source['method_name']];
      }
    }

    return [$duplicates_sources, $duplicates_methods];
  }
887452
private boolean topicImplicity(final String topic, final String[] splitTopic) {

        try {
            return topicMatcher.matches(stripedTopic, this.splitTopic, nonWildCard, endsWithWildCard, rootWildCard, topic, splitTopic);
        } catch (InvalidTopicException e) {
            return false;
        }
    }