STL之list(二)

2023-11-15

// 默认allocator为alloc, 其具体使用版本请参照<stl_alloc.h>
template <class T, class Alloc = alloc>
class list
{
protected:
  typedef void* void_pointer;
  typedef __list_node<T> list_node;

  // 这个提供STL标准的allocator接口
  typedef simple_alloc<list_node, Alloc> list_node_allocator;

public:
  typedef T value_type;
  typedef value_type* pointer;
  typedef const value_type* const_pointer;
  typedef value_type& reference;
  typedef const value_type& const_reference;
  typedef list_node* link_type;
  typedef size_t size_type;
  typedef ptrdiff_t difference_type;

public:
  typedef __list_iterator<T, T&, T*>             iterator;
  typedef __list_iterator<T, const T&, const T*> const_iterator;

#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION
  typedef reverse_iterator<const_iterator> const_reverse_iterator;
  typedef reverse_iterator<iterator> reverse_iterator;
#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */
  typedef reverse_bidirectional_iterator<const_iterator, value_type,
  const_reference, difference_type>
  const_reverse_iterator;
  typedef reverse_bidirectional_iterator<iterator, value_type, reference,
  difference_type>
  reverse_iterator;
#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */

protected:
  // 分配一个新结点, 注意这里并不进行构造,
  // 构造交给全局的construct, 见<stl_stl_uninitialized.h>
  link_type get_node() { return list_node_allocator::allocate(); }

  // 释放指定结点, 不进行析构, 析构交给全局的destroy,
  // 见<stl_stl_uninitialized.h>
  void put_node(link_type p) { list_node_allocator::deallocate(p); }

  // 创建结点, 首先分配内存, 然后进行构造
  // 注: commit or rollback
  link_type create_node(const T& x)
  {
    link_type p = get_node();
    __STL_TRY {
      construct(&p->data, x);
    }
    __STL_UNWIND(put_node(p));
    return p;
  }

  // 析构结点元素, 并释放内存
  void destroy_node(link_type p)
  {
    destroy(&p->data);
    put_node(p);
  }

protected:
  // 用于空链表的建立
  void empty_initialize()
  {
    node = get_node();
    node->next = node;
    node->prev = node;
  }

  // 创建值为value共n个结点的链表
  // 注: commit or rollback
  void fill_initialize(size_type n, const T& value)
  {
    empty_initialize();
    __STL_TRY {
      // 此处插入操作时间复杂度O(1)
      insert(begin(), n, value);
    }
    __STL_UNWIND(clear(); put_node(node));
  }

// 以一个区间初始化链表
// 注: commit or rollback
#ifdef __STL_MEMBER_TEMPLATES
  template <class InputIterator>
  void range_initialize(InputIterator first, InputIterator last)
  {
    empty_initialize();
    __STL_TRY {
      insert(begin(), first, last);
    }
    __STL_UNWIND(clear(); put_node(node));
  }
#else  /* __STL_MEMBER_TEMPLATES */
  void range_initialize(const T* first, const T* last) {
    empty_initialize();
    __STL_TRY {
      insert(begin(), first, last);
    }
    __STL_UNWIND(clear(); put_node(node));
  }
  void range_initialize(const_iterator first, const_iterator last) {
    empty_initialize();
    __STL_TRY {
      insert(begin(), first, last);
    }
    __STL_UNWIND(clear(); put_node(node));
  }
#endif /* __STL_MEMBER_TEMPLATES */

protected:
  // 好吧, 这个是链表头结点, 其本身不保存数据
  link_type node;

public:
  list() { empty_initialize(); }

  iterator begin() { return (link_type)((*node).next); }
  const_iterator begin() const { return (link_type)((*node).next); }

  // 链表成环, 当指所以头节点也就是end
  iterator end() { return node; }
  const_iterator end() const { return node; }
  reverse_iterator rbegin() { return reverse_iterator(end()); }
  const_reverse_iterator rbegin() const {
    return const_reverse_iterator(end());
  }
  reverse_iterator rend() { return reverse_iterator(begin()); }
  const_reverse_iterator rend() const {
    return const_reverse_iterator(begin());
  }

  // 头结点指向自身说明链表中无元素
  bool empty() const { return node->next == node; }

  // 使用全局函数distance()进行计算, 时间复杂度O(n)
  size_type size() const
  {
    size_type result = 0;
    distance(begin(), end(), result);
    return result;
  }

  size_type max_size() const { return size_type(-1); }
  reference front() { return *begin(); }
  const_reference front() const { return *begin(); }
  reference back() { return *(--end()); }
  const_reference back() const { return *(--end()); }
  void swap(list<T, Alloc>& x) { __STD::swap(node, x.node); }


// 在指定位置插入元素

//       insert(iterator position, const T& x)
//                       ↓
//                 create_node(x)
//                 p = get_node();-------->list_node_allocator::allocate();
//                 construct(&p->data, x);
//                       ↓
//            tmp->next = position.node;
//            tmp->prev = position.node->prev;
//            (link_type(position.node->prev))->next = tmp;
//            position.node->prev = tmp;


  iterator insert(iterator position, const T& x)
  {
    link_type tmp = create_node(x);
    tmp->next = position.node;
    tmp->prev = position.node->prev;
    (link_type(position.node->prev))->next = tmp;
    position.node->prev = tmp;
    return tmp;
  }

  iterator insert(iterator position) { return insert(position, T()); }
#ifdef __STL_MEMBER_TEMPLATES
  template <class InputIterator>
  void insert(iterator position, InputIterator first, InputIterator last);
#else /* __STL_MEMBER_TEMPLATES */
  void insert(iterator position, const T* first, const T* last);
  void insert(iterator position,
              const_iterator first, const_iterator last);
#endif /* __STL_MEMBER_TEMPLATES */

  // 指定位置插入n个值为x的元素, 详细解析见实现部分
  void insert(iterator pos, size_type n, const T& x);
  void insert(iterator pos, int n, const T& x)
  {
    insert(pos, (size_type)n, x);
  }
  void insert(iterator pos, long n, const T& x)
  {
    insert(pos, (size_type)n, x);
  }

  // 在链表前端插入结点
  void push_front(const T& x) { insert(begin(), x); }
  // 在链表最后插入结点
  void push_back(const T& x) { insert(end(), x); }

  // 擦除指定结点
  iterator erase(iterator position)
  {
    link_type next_node = link_type(position.node->next);
    link_type prev_node = link_type(position.node->prev);
    prev_node->next = next_node;
    next_node->prev = prev_node;
    destroy_node(position.node);
    return iterator(next_node);
  }

  // 擦除一个区间的结点, 详细解析见实现部分
  iterator erase(iterator first, iterator last);

  void resize(size_type new_size, const T& x);
  void resize(size_type new_size) { resize(new_size, T()); }
  void clear();

  // 删除链表第一个结点
  void pop_front() { erase(begin()); }
  // 删除链表最后一个结点
  void pop_back()
  {
    iterator tmp = end();
    erase(--tmp);
  }

  list(size_type n, const T& value) { fill_initialize(n, value); }
  list(int n, const T& value) { fill_initialize(n, value); }
  list(long n, const T& value) { fill_initialize(n, value); }

  explicit list(size_type n) { fill_initialize(n, T()); }

// 以一个区间元素为蓝本创建链表
#ifdef __STL_MEMBER_TEMPLATES
  template <class InputIterator>
  list(InputIterator first, InputIterator last)
  {
    range_initialize(first, last);
  }

#else /* __STL_MEMBER_TEMPLATES */
  list(const T* first, const T* last) { range_initialize(first, last); }
  list(const_iterator first, const_iterator last) {
    range_initialize(first, last);
  }
#endif /* __STL_MEMBER_TEMPLATES */

  // 复制构造
  list(const list<T, Alloc>& x)
  {
    range_initialize(x.begin(), x.end());
  }

  ~list()
  {
    // 释放所有结点  // 使用全局函数distance()进行计算, 时间复杂度O(n)
  size_type size() const
  {
    size_type result = 0;
    distance(begin(), end(), result);
    return result;
  }
    clear();
    // 释放头结点
    put_node(node);
  }

  list<T, Alloc>& operator=(const list<T, Alloc>& x);

protected:


// 将[first, last)区间插入到position
// 如果last == position, 则相当于链表不变化, 不进行操作

// 初始状态
//                   first                             last
//                     ↓                                 ↓
//      --------   --------   --------     --------   --------   --------
//      | next |-->| next |-->| next |     | next |-->| next |-->| next |
//  ... --------   --------   -------- ... --------   --------   -------- ...
//      | prev |<--| prev |<--| prev |     | prev |<--| prev |<--| prev |
//      --------   --------   --------     --------   --------   --------
//
//                           position
//                               ↓
//      --------   --------   --------   --------   --------   --------
//      | next |-->| next |-->| next |-->| next |-->| next |-->| next |
//  ... --------   --------   --------   --------   --------   -------- ...
//      | prev |<--| prev |<--| prev |<--| prev |<--| prev |<--| prev |
//      --------   --------   --------   --------   --------   --------
//
// 操作完成后状态
//                           first
//                             |
//               --------------|--------------------------------------
//               | ------------|------------------------------------ |   last
//               | |           ↓                                   | |     ↓
//      -------- | |        --------   --------     --------       | |  --------   --------
//      | next |-- |  ----->| next |-->| next |     | next |-----  | -->| next |-->| next |
//  ... --------   |  |     --------   -------- ... --------    |  |    --------   -------- ...
//      | prev |<---  |  ---| prev |<--| prev |     | prev |<-- |  -----| prev |<--| prev |
//      --------      |  |  --------   --------     --------  | |       --------   --------
//                    |  |                                    | |
//                    |  ------                               | |
//                    ------- |  ------------------------------ |
//                          | |  |                              |
//                          | |  |  -----------------------------
//                          | |  |  |
//                          | |  |  |  position
//                          | |  |  |     ↓
//      --------   -------- | |  |  |  --------   --------   --------   --------
//      | next |-->| next |-- |  |  -->| next |-->| next |-->| next |-->| next |
//  ... --------   --------   |  |     --------   --------   --------   -------- ...
//      | prev |<--| prev |<---  ------| prev |<--| prev |<--| prev |<--| prev |
//      --------   --------            --------   --------   --------   --------

  void transfer(iterator position, iterator first, iterator last)
  {
    if (position != last)
    {
      (*(link_type((*last.node).prev))).next = position.node;
      (*(link_type((*first.node).prev))).next = last.node;
      (*(link_type((*position.node).prev))).next = first.node;
      link_type tmp = link_type((*position.node).prev);
      (*position.node).prev = (*last.node).prev;
      (*last.node).prev = (*first.node).prev;
      (*first.node).prev = tmp;
    }
  }

public:
  // 将链表x移动到position之前
  void splice(iterator position, list& x)
  {
    if (!x.empty())
      transfer(position, x.begin(), x.end());
  }

  // 将链表中i指向的内容移动到position之前
  void splice(iterator position, list&, iterator i)
  {
    iterator j = i;
    ++j;
    if (position == i || position == j) return;
    transfer(position, i, j);
  }

  // 将[first, last}元素移动到position之前
  void splice(iterator position, list&, iterator first, iterator last)
  {
    if (first != last)
      transfer(position, first, last);
  }

  void remove(const T& value);
  void unique();
  void merge(list& x);
  void reverse();
  void sort();

#ifdef __STL_MEMBER_TEMPLATES
  template <class Predicate> void remove_if(Predicate);
  template <class BinaryPredicate> void unique(BinaryPredicate);
  template <class StrictWeakOrdering> void merge(list&, StrictWeakOrdering);
  template <class StrictWeakOrdering> void sort(StrictWeakOrdering);
#endif /* __STL_MEMBER_TEMPLATES */

  friend bool operator== __STL_NULL_TMPL_ARGS (const list& x, const list& y);
};

// 判断两个链表是否相等
template <class T, class Alloc>
inline bool operator==(const list<T,Alloc>& x, const list<T,Alloc>& y)
{
  typedef typename list<T,Alloc>::link_type link_type;
  link_type e1 = x.node;
  link_type e2 = y.node;
  link_type n1 = (link_type) e1->next;
  link_type n2 = (link_type) e2->next;
  for ( ; n1 != e1 && n2 != e2 ;
          n1 = (link_type) n1->next, n2 = (link_type) n2->next)
    if (n1->data != n2->data)
      return false;
  return n1 == e1 && n2 == e2;
}

// 链表比较大小使用的是字典顺序
template <class T, class Alloc>
inline bool operator<(const list<T, Alloc>& x, const list<T, Alloc>& y)
{
  return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
}

// 如果编译器支持模板函数特化优先级
// 那么将全局的swap实现为使用list私有的swap以提高效率
#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER

template <class T, class Alloc>
inline void swap(list<T, Alloc>& x, list<T, Alloc>& y)
{
  x.swap(y);
}

#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */

// 将[first, last)区间插入到position之前
#ifdef __STL_MEMBER_TEMPLATES

template <class T, class Alloc> template <class InputIterator>
void list<T, Alloc>::insert(iterator position,
                            InputIterator first, InputIterator last)
{
  for ( ; first != last; ++first)
    insert(position, *first);
}

#else /* __STL_MEMBER_TEMPLATES */

template <class T, class Alloc>
void list<T, Alloc>::insert(iterator position, const T* first, const T* last) {
  for ( ; first != last; ++first)
    insert(position, *first);
}

template <class T, class Alloc>
void list<T, Alloc>::insert(iterator position,
                            const_iterator first, const_iterator last) {
  for ( ; first != last; ++first)
    insert(position, *first);
}

#endif /* __STL_MEMBER_TEMPLATES */

// 在position前插入n个值为x的元素
template <class T, class Alloc>
void list<T, Alloc>::insert(iterator position, size_type n, const T& x)
{
  for ( ; n > 0; --n)
    insert(position, x);
}

// 擦除[first, last)间的结点
template <class T, class Alloc>
list<T,Alloc>::iterator list<T, Alloc>::erase(iterator first, iterator last)
{
  while (first != last) erase(first++);
  return last;
}

// 重新设置容量大小
// 如果当前容量小于新容量, 则新增加值为x的元素, 使容量增加至新指定大小
// 如果当前容量大于新容量, 则析构出来的元素
template <class T, class Alloc>
void list<T, Alloc>::resize(size_type new_size, const T& x)
{
  iterator i = begin();
  size_type len = 0;
  for ( ; i != end() && len < new_size; ++i, ++len)
    ;
  if (len == new_size)
    erase(i, end());
  else                          // i == end()
    insert(end(), new_size - len, x);
}

// 销毁所有结点, 将链表置空
template <class T, class Alloc>
void list<T, Alloc>::clear()
{
  link_type cur = (link_type) node->next;
  while (cur != node) {
    link_type tmp = cur;
    cur = (link_type) cur->next;
    destroy_node(tmp);
  }
  node->next = node;
  node->prev = node;
}

// 链表赋值操作
// 如果当前容器元素少于x容器, 则析构多余元素,
// 否则将调用insert插入x中剩余的元素
template <class T, class Alloc>
list<T, Alloc>& list<T, Alloc>::operator=(const list<T, Alloc>& x)
{
  if (this != &x) {
    iterator first1 = begin();
    iterator last1 = end();
    const_iterator first2 = x.begin();
    const_iterator last2 = x.end();
    while (first1 != last1 && first2 != last2) *first1++ = *first2++;
    if (first2 == last2)
      erase(first1, last1);
    else
      insert(last1, first2, last2);
  }
  return *this;
}

// 移除特定值的所有结点
// 时间复杂度O(n)
template <class T, class Alloc>
void list<T, Alloc>::remove(const T& value)
{
  iterator first = begin();
  iterator last = end();
  while (first != last) {
    iterator next = first;
    ++next;
    if (*first == value) erase(first);
    first = next;
  }
}

// 移除容器内所有的相邻的重复结点
// 时间复杂度O(n)
// 用户自定义数据类型需要提供operator ==()重载
template <class T, class Alloc>
void list<T, Alloc>::unique()
{
  iterator first = begin();
  iterator last = end();
  if (first == last) return;
  iterator next = first;
  while (++next != last) {
    if (*first == *next)
      erase(next);
    else
      first = next;
    next = first;
  }
}

// 假设当前容器和x都已序, 保证两容器合并后仍然有序
template <class T, class Alloc>
void list<T, Alloc>::merge(list<T, Alloc>& x)
{
  iterator first1 = begin();
  iterator last1 = end();
  iterator first2 = x.begin();
  iterator last2 = x.end();
  while (first1 != last1 && first2 != last2)
    if (*first2 < *first1) {
      iterator next = first2;
      transfer(first1, first2, ++next);
      first2 = next;
    }
    else
      ++first1;
  if (first2 != last2) transfer(last1, first2, last2);
}

// 将链表倒置
// 其算法核心是历遍链表, 每次取出一个结点, 并插入到链表起始点
// 历遍完成后链表满足倒置
template <class T, class Alloc>
void list<T, Alloc>::reverse()
{
  if (node->next == node || link_type(node->next)->next == node) return;
  iterator first = begin();
  ++first;
  while (first != end()) {
    iterator old = first;
    ++first;
    transfer(begin(), old, first);
  }
}

// 按照升序排序
template <class T, class Alloc>
void list<T, Alloc>::sort()
{
  if (node->next == node || link_type(node->next)->next == node) return;
  list<T, Alloc> carry;
  list<T, Alloc> counter[64];
  int fill = 0;
  while (!empty()) {
    carry.splice(carry.begin(), *this, begin());
    int i = 0;
    while(i < fill && !counter[i].empty()) {
      counter[i].merge(carry);
      carry.swap(counter[i++]);
    }
    carry.swap(counter[i]);
    if (i == fill) ++fill;
  }

  for (int i = 1; i < fill; ++i) counter[i].merge(counter[i-1]);
  swap(counter[fill-1]);
}

#ifdef __STL_MEMBER_TEMPLATES

// 给定一个仿函数, 如果仿函数值为真则进行相应元素的移除
template <class T, class Alloc> template <class Predicate>
void list<T, Alloc>::remove_if(Predicate pred)
{
  iterator first = begin();
  iterator last = end();
  while (first != last) {
    iterator next = first;
    ++next;
    if (pred(*first)) erase(first);
    first = next;
  }
}

// 根据仿函数, 决定如何移除相邻的重复结点
template <class T, class Alloc> template <class BinaryPredicate>
void list<T, Alloc>::unique(BinaryPredicate binary_pred)
{
  iterator first = begin();
  iterator last = end();
  if (first == last) return;
  iterator next = first;
  while (++next != last) {
    if (binary_pred(*first, *next))
      erase(next);
    else
      first = next;
    next = first;
  }
}

// 假设当前容器和x均已序, 将x合并到当前容器中, 并保证在comp仿函数
// 判定下仍然有序
template <class T, class Alloc> template <class StrictWeakOrdering>
void list<T, Alloc>::merge(list<T, Alloc>& x, StrictWeakOrdering comp)
{
  iterator first1 = begin();
  iterator last1 = end();
  iterator first2 = x.begin();
  iterator last2 = x.end();
  while (first1 != last1 && first2 != last2)
    if (comp(*first2, *first1)) {
      iterator next = first2;
      transfer(first1, first2, ++next);
      first2 = next;
    }
    else
      ++first1;
  if (first2 != last2) transfer(last1, first2, last2);
}

// 根据仿函数comp据定如何排序
template <class T, class Alloc> template <class StrictWeakOrdering>
void list<T, Alloc>::sort(StrictWeakOrdering comp)
{
  if (node->next == node || link_type(node->next)->next == node) return;
  list<T, Alloc> carry;
  list<T, Alloc> counter[64];
  int fill = 0;
  while (!empty()) {
    carry.splice(carry.begin(), *this, begin());
    int i = 0;
    while(i < fill && !counter[i].empty()) {
      counter[i].merge(carry, comp);
      carry.swap(counter[i++]);
    }
    carry.swap(counter[i]);
    if (i == fill) ++fill;
  }

  for (int i = 1; i < fill; ++i) counter[i].merge(counter[i-1], comp);
  swap(counter[fill-1]);
}

#endif /* __STL_MEMBER_TEMPLATES */

#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
#pragma reset woff 1174
#endif

__STL_END_NAMESPACE

#endif /* __SGI_STL_INTERNAL_LIST_H */

参考:https://www.cnblogs.com/lfsblack/archive/2012/11/10/2764334.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

STL之list(二) 的相关文章

  • 10.1-迁移学习

    迁移学习指的就是 假设你手上有一些跟你现在要进行的task没有直接相关的data 那你能不能用这些没有直接相关的data来帮助我们做一些什么事情 比如说 你现在做的是猫跟狗的classifer 那所谓没有什么直接相关的data是什么意思呢
  • win10 wsl 安装 ubuntu 16.04

    背景 因为大多数是在单系统上开发 现在想装win10 ubuntu共存 但双系统切换好麻烦 于是有了在win10里利用wsl装子系统的想法 操作 启动wsl 因为微软商店没有ubuntu16 04 于是到官网下载ubuntu16 04 其他
  • 解决Vue引用Swiper4插件无法重写分页器样式问题

    最近在尝试用nuxtjs来搭建新的站点 但是平时在jquery里面用惯的一些插件一到vue上面引用就各种不顺畅 本文记录一下在用Swiper插件来做轮播图的时候遇到的问题 至于怎么在vue里面引用插件就不累赘了 npm能告诉你 Swiper
  • 一个小时内学习 SQLite 数据库

    SQLite 是一个开源的嵌入式关系数据库 实现自包容 零配置 支持事务的SQL数据库引擎 其特点是高度便携 使用方便 结构紧凑 高效 可靠 与其他数据库管理系统不同 SQLite 的安装和运行非常简单 在大多数情况下 只要确保SQLite
  • 好用的插件介绍-Clear Cache Chrome插件

    clear cache插件是一款用于清理谷歌浏览器的chrome清理缓存插件 该插件支持清理应用程序缓存 缓存 Cookie 下载 文件系统 表单数据 历史 索引数据库 本地存储 插件数据 密码和WebSQL 你只需要在安装了这款插件后在设
  • VSCode中Python代码自动提示

    自己写的模块 VSCode中无法自动提示 可以按下面步骤试试 1 添加模块路径 文件 设置 首选项 搜索autoComplete 点击 在settings json中编辑 添加模块路径 python autoComplete extraPa
  • nrm安装与配置

    1 nrm安装与配置 npm 介绍 nrm npm registry manager 是npm的镜像源管理工具 有时候国外资源太慢 使用这个就可以快速地在 npm 源间切换 参考文章 西北码农 安装 在命令行执行命令 npm install
  • html 邮件乱码怎么办,如何解决html邮件乱码问题

    html邮件乱码的解决办法 1 在mail函数前一行打印message内容 2 将邮件内容保存为html文件后查看 3 设置UTF 8编码 本文操作环境 windows7系统 HTML5版 Dell G3电脑 如何解决html邮件乱码问题
  • Jenkins 持续集成:Linux 系统 两台机器互相免密登录

    背景知识 我们把public key放在远程系统合适的位置 然后从本地开始进行ssh连接 此时 远程的sshd会产生一个随机数并用我们产生的public key进行加密后发给本地 本地会用private key进行解密并把这个随机数发回给远
  • day21

    530 二叉搜索树的最小绝对差 先转换为有序list 再比较差值 501 二叉搜索树中的众数 先转换为有序list 再进行众数统计寻找 236 二叉树的最近公共祖先 后序遍历 再根据返回的值寻找祖先 package algor traini

随机推荐

  • 3d打印,机器人,计算机,3D打印的机器人将教孩子计算机编码!

    原标题 3D打印的机器人将教孩子计算机编码 随着我们的世界变得日益数字化的 越来越多的编码和计算机编程工作如雨后春笋般冒出 需要越来越多的人在编码语言 成为精通 这种先进的计算机知识将更加为下一代更重要 因为2024年 超过100万以上的编
  • Linux 三分钟学会虚拟机与外网和主机互通

    首先准备好一台安装好的虚拟机 字符界面也一样 配置虚拟网卡 添加一张虚拟网卡用来连接主机和虚拟机 通过图中步骤设置好 最后和最后那张图显示一样 确定 右击需要配置网络的虚拟机 单击添加 选中网络适配器 然后单击确定 点击自定义 然后选择刚刚
  • C++ 多态虚函数表(VS2013)

    对于含有虚函数的类 基类或者自身 自身非纯虚函数 的对象 都拥有一个指向虚函数表的指针 占一个指针大小的内存 在类成员变量之前 相当于第一个成员变量 多重继承的时候 几个基类就几个指针 就几个虚函数表 每个类的虚函数表确定了各个方法指向那个
  • Hadoop3.0.3 HDFS 常用shell 命令

    1 启动Hadoop start all sh root elk server sbin start all sh Starting namenodes on elk server 上一次登录 日 11月 24 21 57 43 CST 2
  • 【linux多线程(四)】——线程池的详细解析(含代码)

    目录 什么是线程池 线程池的应用场景 线程池的实现 线程池的代码 C linux线程 壹 初识线程 区分线程和进程 线程创建的基本操作 线程 二 互斥量的详细解析 线程 三 条件变量的详细解析 什么是线程池 线程池是一种线程使用模式 它是将
  • GDB 和 windbg 命令对照(转载)

    From http blog csdn net joeleechj article details 10020501 命令 windbg gdb 附加 attach attach 脱离附加 detach detach 运
  • CSS总结div中的内容垂直居中的六种方法

    一 行高 line height 法如果要垂直居中的只有一行或几个文字 那它的制作最为简单 只要让文字的行高和容器的高度相同即可 比如 p height 30px line height 30px width 100px overflow
  • VMware vSphere中三种磁盘规格(厚置备延迟置零\厚置备置零\Thin Provision

    在VMware vSphere中 不管是以前的5 1版本 或者是现在的6 5版本 创建虚拟机时 在创建磁盘时 都会让选择磁盘的置备类型 如下图所示 分为 1 厚置备延迟置零 2 厚置备置零 3 Thin Provision 精简置备 在创建
  • unity 基本寻径

    一 实现效果 敌人追逐玩家 自动躲避障碍物 二 游戏框架 Plane 平面 是玩家和敌人可以行走的区域 Player 玩家 可以在平面上移动 绕开障碍物 Enemy 敌人 可以追逐玩家 绕开障碍物 障碍物 五个正方体 玩家在移动的过程中和敌
  • java中,在一个类中调用另一个类的属性和方法

    在java当中 在一个类中调用另一个类的情况有多种 可能是调用不同包中的类 也可能是同包不同类 如果调用不同包中的类 需要先导入该包 然后才能调用 这里主要分享一个调用同包中的不同类的属性和方法的操作 比如这里有一个Card类和一个Card
  • ubuntu apt update 报错Err:6 https://download.docker.com/linux/ubuntu jammy InRelease

    目录 尝试清除已存在的软件源信息并重新添加 重新配置ubunut镜像源 我这边用的是阿里云的源 阿里源配置 Ubuntu换阿里云源后更新提示 GPG error缺少公钥解决方法 尝试清除已存在的软件源信息并重新添加 Clear your p
  • oracle.数据的增删改、事务、创建表、修改表、删除表

    一 数据的增删改 1 备份表 01 全表备份 CREATE TABLE 新表名 AS 子查询 将emp表全表备份 CREATE TABLE emp bak AS SELECT FROM emp SELECT FROM emp bak 02
  • java JLabel改变大小后如何刷新_到底一行java代码是如何在计算机上执行的

    不知道你是否思考过 每次我们在IDEA中右键Run Application启动主方法 假如程序运行正常 控制台也打印出了你所要打印的信息 在这个过程中你知道这台计算机上那些硬件及其软件都是以什么样的方式参与到这个过程吗 今天我们就分析梳理下
  • Java对正则表达式的支持(手机、身份证校验)

    目录 1 数量 单个 字符匹配 2 数量 单个 字符集 可以从里面任选一个字符 3 数量 单个 简化字符集 4 边界匹配 5 数量表示 默认情况下只有添加上了数量单位才可以匹配多位字符 6 逻辑表达式 可以连接多个正则 7 理解字符 的含义
  • OpenMMLab MMDetectionV3.1.0-SAM(环境安装、模型测试、训练以及模型后处理工具)

    OpenMMLab Playground 概况 当前通用目标检测的研究方向正在朝着大型多模态模型发展 除了图像输入之外 最近的研究成果还结合了文本模式来提高性能 添加文本模态后 通用检测算法的一些非常好的属性开始出现 例如 可以利用大量易于
  • UE4 自定义鼠标样式

    主要内容 在项目制作中我们往往不会使用默认的鼠标样式 这时就需要自定义鼠标样式 具体实现步骤就是创建一个带有图片的UI蓝图然后在项目设置里的UserInterface里进行设置 实现步骤 1 新建UI蓝图 添加一个Image控件把锚点设置成
  • 电容降压主要是用在直流稳压电源电路里

    https www cnblogs com jarvise p 4647029 html 基本原理 电容降压主要是用在直流稳压电源电路里 直流稳压电源电路的大致结构是 市电 变压 降压 整流 滤波 稳压 直流输出 变压 主要是降压 一般使用
  • 非线性微分跟踪器

    微分器描述 离散形式的非线性微分跟踪为 其中 h为采样周期 v k 为第k时刻的输入信号 为决定跟踪快慢的系数 fst 为最速控制综合函数 描述如下 仿真分析 微分器测试 输入信号v t sin2pit 采样周期h 0 001 150 扰动
  • 高性能本地存储设计

    本地存储常规架构 通用的云本地存储常规架构如下图所示 以MySQL数据库为例 它通过POSIX API与云主机内核交互 云主机内核包括一个标准文件系统和标准的块设备接口 云主机内核下面是云物理机内核 它自上而下由标准文件系统 标准块设备接口
  • STL之list(二)

    默认allocator为alloc 其具体使用版本请参照