当前位置: 首页>>代码示例>>C++>>正文


C++ HeapVector::contains方法代码示例

本文整理汇总了C++中HeapVector::contains方法的典型用法代码示例。如果您正苦于以下问题:C++ HeapVector::contains方法的具体用法?C++ HeapVector::contains怎么用?C++ HeapVector::contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HeapVector的用法示例。


在下文中一共展示了HeapVector::contains方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateElement

TEST_F(CustomElementRegistryTest, collectCandidates_oneCandidate) {
  Element* element = CreateElement("a-a").inDocument(&document());
  registry().addCandidate(element);
  document().documentElement()->appendChild(element);

  HeapVector<Member<Element>> elements;
  collectCandidates(CustomElementDescriptor("a-a", "a-a"), &elements);

  EXPECT_EQ(1u, elements.size())
      << "exactly one candidate should have been found";
  EXPECT_TRUE(elements.contains(element))
      << "the candidate should be the element that was added";
}
开发者ID:,项目名称:,代码行数:13,代码来源:

示例2: document

TEST_F(CustomElementUpgradeSorterTest, oneCandidate) {
  NonThrowableExceptionState noExceptions;
  Element* element =
      document()->createElement("a-a", StringOrDictionary(), noExceptions);
  document()->documentElement()->appendChild(element);

  CustomElementUpgradeSorter sorter;
  sorter.add(element);

  HeapVector<Member<Element>> elements;
  sorter.sorted(&elements, document());
  EXPECT_EQ(1u, elements.size())
      << "exactly one candidate should be in the result set";
  EXPECT_TRUE(elements.contains(element))
      << "the candidate should be the element that was added";
}
开发者ID:mirror,项目名称:chromium,代码行数:16,代码来源:CustomElementUpgradeSorterTest.cpp

示例3: updateActiveCues

void CueTimeline::updateActiveCues(double movieTime) {
  // 4.8.10.8 Playing the media resource

  //  If the current playback position changes while the steps are running,
  //  then the user agent must wait for the steps to complete, and then must
  //  immediately rerun the steps.
  if (ignoreUpdateRequests())
    return;

  HTMLMediaElement& mediaElement = this->mediaElement();

  // Don't run the "time marches on" algorithm if the document has been
  // detached. This primarily guards against dispatch of events w/
  // HTMLTrackElement targets.
  if (mediaElement.document().isDetached())
    return;

  // https://html.spec.whatwg.org/#time-marches-on

  // 1 - Let current cues be a list of cues, initialized to contain all the
  // cues of all the hidden, showing, or showing by default text tracks of the
  // media element (not the disabled ones) whose start times are less than or
  // equal to the current playback position and whose end times are greater
  // than the current playback position.
  CueList currentCues;

  // The user agent must synchronously unset [the text track cue active] flag
  // whenever ... the media element's readyState is changed back to
  // kHaveNothing.
  if (mediaElement.getReadyState() != HTMLMediaElement::kHaveNothing &&
      mediaElement.webMediaPlayer())
    currentCues =
        m_cueTree.allOverlaps(m_cueTree.createInterval(movieTime, movieTime));

  CueList previousCues;
  CueList missedCues;

  // 2 - Let other cues be a list of cues, initialized to contain all the cues
  // of hidden, showing, and showing by default text tracks of the media
  // element that are not present in current cues.
  previousCues = m_currentlyActiveCues;

  // 3 - Let last time be the current playback position at the time this
  // algorithm was last run for this media element, if this is not the first
  // time it has run.
  double lastTime = m_lastUpdateTime;
  double lastSeekTime = mediaElement.lastSeekTime();

  // 4 - If the current playback position has, since the last time this
  // algorithm was run, only changed through its usual monotonic increase
  // during normal playback, then let missed cues be the list of cues in other
  // cues whose start times are greater than or equal to last time and whose
  // end times are less than or equal to the current playback position.
  // Otherwise, let missed cues be an empty list.
  if (lastTime >= 0 && lastSeekTime < movieTime) {
    CueList potentiallySkippedCues =
        m_cueTree.allOverlaps(m_cueTree.createInterval(lastTime, movieTime));

    for (CueInterval cue : potentiallySkippedCues) {
      // Consider cues that may have been missed since the last seek time.
      if (cue.low() > std::max(lastSeekTime, lastTime) &&
          cue.high() < movieTime)
        missedCues.append(cue);
    }
  }

  m_lastUpdateTime = movieTime;

  // 5 - If the time was reached through the usual monotonic increase of the
  // current playback position during normal playback, and if the user agent
  // has not fired a timeupdate event at the element in the past 15 to 250ms
  // and is not still running event handlers for such an event, then the user
  // agent must queue a task to fire a simple event named timeupdate at the
  // element. (In the other cases, such as explicit seeks, relevant events get
  // fired as part of the overall process of changing the current playback
  // position.)
  if (!mediaElement.seeking() && lastSeekTime < lastTime)
    mediaElement.scheduleTimeupdateEvent(true);

  // Explicitly cache vector sizes, as their content is constant from here.
  size_t missedCuesSize = missedCues.size();
  size_t previousCuesSize = previousCues.size();

  // 6 - If all of the cues in current cues have their text track cue active
  // flag set, none of the cues in other cues have their text track cue active
  // flag set, and missed cues is empty, then abort these steps.
  bool activeSetChanged = missedCuesSize;

  for (size_t i = 0; !activeSetChanged && i < previousCuesSize; ++i) {
    if (!currentCues.contains(previousCues[i]) &&
        previousCues[i].data()->isActive())
      activeSetChanged = true;
  }

  for (CueInterval currentCue : currentCues) {
    // Notify any cues that are already active of the current time to mark
    // past and future nodes. Any inactive cues have an empty display state;
    // they will be notified of the current time when the display state is
    // updated.
    if (currentCue.data()->isActive())
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的HeapVector::contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。