qt-C++笔记之QStringList

qt-C++笔记之QStringList

—— 杭州 2023-12-03

code review!

文章目录

  • qt-C++笔记之QStringList
    • 1.1.《Qt官方文档》第一部分翻译:继承自QList\<QString\>-初始化-添加字符串
    • 1.2.迭代字符串
    • 1.3.join()和split()
    • 1.4.filter()
    • 1.5.lastIndexOf()
    • 1.6.indexOf()
    • 1.7.replaceInStrings()以及比较QString 类则提供了replace()函数
    • 1.8.一些常用方法和操作
    • 1.9.QStringList和QList<QString>关系
    • 2.0.QStringList的append(),append(),operator+()
    • 2.1.QStringLis:Public Functions
    • 2.2.QStringLis:List of all members, including inherited members
    • 2.3.Classes for String Data(Qt中字符串数据的类)

**《Qt官方文档》链接:**

https://doc.qt.io/qt-6/qstringlist.html

1.1.《Qt官方文档》第一部分翻译:继承自QList<QString>-初始化-添加字符串

原文:

在这里插入图片描述

翻译:

在这里插入图片描述

1.2.迭代字符串

在Qt中,遍历 QStringList 可以使用迭代器、foreach 循环或基于索引的循环。下面是这些遍历方法的详细说明:

  1. 使用迭代器:

    QStringList stringList;
    stringList << "Apple" << "Banana" << "Cherry";
    
    QStringList::iterator it;
    for (it = stringList.begin(); it != stringList.end(); ++it) {
        qDebug() << *it;
    }
    ```
    
    使用迭代器可遍历 `QStringList`,通过 `begin()` 获取迭代器的起始位置,通过 `end()` 获取迭代器的结束位置。在循环中,使用 `*it` 来访问迭代器当前指向的元素。
    
    
  2. 使用 foreach 循环:

    QStringList stringList;
    stringList << "Apple" << "Banana" << "Cherry";
    
    foreach (const QString& str, stringList) {
        qDebug() << str;
    }
    ```
    
    ``foreach` 循环提供了一种简洁的方式来遍历 `QStringList`。在每次迭代中,变量 `str` 将依次引用列表中的元素。
    
    
  3. 基于索引的循环:

    QStringList stringList;
    stringList << "Apple" << "Banana" << "Cherry";
    
    for (int i = 0; i < stringList.size(); ++i) {
        qDebug() << stringList.at(i);
    }
    

    基于索引的循环遍历 QStringList 可以使用下标运算符 []at() 函数来访问列表中的元素。以下是基于索引的循环遍历的详细说明:

    QStringList stringList;
    stringList << "Apple" << "Banana" << "Cherry";
    
    for (int i = 0; i < stringList.size(); ++i) {
        QString str = stringList[i]; // 或者使用 stringList.at(i)
        qDebug() << str;
    }
    

    在上述示例中,我们创建了一个 QStringList 对象 stringList,其中包含多个字符串元素。然后,我们使用基于索引的循环遍历列表。在每次迭代中,我们使用下标运算符 []at() 函数来获取列表中的元素并将其存储在 str 变量中。最后,我们输出 str 的值。

    需要注意的是,索引从 0 开始,因此循环条件是 i < stringList.size()。我们使用 size() 函数获取列表的大小。

1.3.join()和split()

在这里插入图片描述

1.4.filter()

在这里插入图片描述

以下是一个完整的示例代码:

#include <QtCore>

int main() {
    QStringList fonts;
    fonts << "Arial" << "Courier New" << "Times New Roman" << "Fixedsys";

    QStringList monospacedFonts = fonts.filter(QRegularExpression("Courier|Fixed"));

    qDebug() << "Monospaced Fonts:";
    for (const QString& font : monospacedFonts) {
        qDebug() << font;
    }

    return 0;
}

在这个示例中,我们先创建了一个 QStringList 对象 fonts,并向其添加了几个字体名称。然后,使用 filter() 函数结合正则表达式 "Courier|Fixed" 筛选出包含 “Courier” 或 “Fixed” 的字体名称,并将结果存储在 monospacedFonts 中。

最后,通过遍历 monospacedFonts,将筛选结果输出到调试输出中。

运行这段代码,你将得到如下输出结果:

Monospaced Fonts:
"Courier New"
"Fixedsys"

输出结果显示了满足条件的字体名称,即 “Courier New” 和 “Fixedsys”。这表明代码成功地筛选出了包含 “Courier” 或 “Fixed” 的字体名称。

1.5.lastIndexOf()

QStringList 类提供了 lastIndexOf() 函数用于查找指定字符串在列表中最后出现的位置(索引)。

函数原型如下:

int lastIndexOf(const QString& value, int from = -1) const;

参数说明:

  • value:要查找的字符串。
  • from:可选参数,指定开始搜索的索引位置,默认值为 -1,表示从列表的末尾开始搜索。

函数返回值:

  • 如果找到了指定的字符串,则返回最后一个匹配项的索引值。
  • 如果没有找到匹配项,则返回 -1。

以下是一个示例,演示如何使用 lastIndexOf() 函数查找字符串在 QStringList 中最后出现的位置:

#include <QtCore>

int main() {
    QStringList stringList;
    stringList << "Apple" << "Banana" << "Cherry" << "Banana" << "Apple";

    int lastIndex = stringList.lastIndexOf("Banana");
    if (lastIndex != -1) {
        qDebug() << "Last occurrence of 'Banana' found at index:" << lastIndex;
    } else {
        qDebug() << "No occurrence of 'Banana' found in the list.";
    }

    return 0;
}

在上述示例中,我们创建了一个 QStringList 对象 stringList,其中包含多个字符串元素。然后,我们使用 lastIndexOf() 函数查找字符串 “Banana” 在列表中最后出现的位置,并将结果存储在 lastIndex 中。

最后,我们根据 lastIndex 的值输出相应的信息。

运行这段代码,你将得到如下输出结果:

Last occurrence of 'Banana' found at index: 3

输出结果表明,字符串 “Banana” 在列表中最后出现的位置是索引 3。

1.6.indexOf()

QStringList 类提供了 indexOf() 函数用于查找指定字符串在列表中第一次出现的位置(索引)。

函数原型如下:

int indexOf(const QString& value, int from = 0) const;

参数说明:

  • value:要查找的字符串。
  • from:可选参数,指定开始搜索的索引位置,默认值为 0,表示从列表的开头开始搜索。

函数返回值:

  • 如果找到了指定的字符串,则返回第一个匹配项的索引值。
  • 如果没有找到匹配项,则返回 -1。

以下是一个示例,演示如何使用 indexOf() 函数查找字符串在 QStringList 中第一次出现的位置:

#include <QtCore>

int main() {
    QStringList stringList;
    stringList << "Apple" << "Banana" << "Cherry" << "Banana" << "Apple";

    int firstIndex = stringList.indexOf("Banana");
    if (firstIndex != -1) {
        qDebug() << "First occurrence of 'Banana' found at index:" << firstIndex;
    } else {
        qDebug() << "No occurrence of 'Banana' found in the list.";
    }

    return 0;
}

在上述示例中,我们创建了一个 QStringList 对象 stringList,其中包含多个字符串元素。然后,我们使用 indexOf() 函数查找字符串 “Banana” 在列表中第一次出现的位置,并将结果存储在 firstIndex 中。

最后,我们根据 firstIndex 的值输出相应的信息。

运行这段代码,你将得到如下输出结果:

First occurrence of 'Banana' found at index: 1

输出结果表明,字符串 “Banana” 在列表中第一次出现的位置是索引 1。

1.7.replaceInStrings()以及比较QString 类则提供了replace()函数

在这里插入图片描述

QStringList 类提供了一个成员函数 replaceInStrings(),用于在列表中的每个字符串中进行替换操作。而 QString 类则提供了 replace() 函数,用于执行单个字符串的替换操作。

  1. QStringList::replaceInStrings(const QString& before, const QString& after)

    • 此函数用于在列表中的每个字符串中将 before 替换为 after
    • 它会修改原始的 QStringList 对象,将所有匹配的字符串进行替换。
    • 示例:
    QStringList stringList;
    stringList << "apple" << "banana" << "cherry";
    
    stringList.replaceInStrings("a", "X");
    
    // 输出结果: "Xpple", "bXnXnX", "cherry"
    qDebug() << stringList;
    ```
    
    
  2. QString::replace(const QString& before, const QString& after)

    • 此函数用于在单个字符串中将 before 替换为 after
    • 它返回一个新的字符串,不会修改原始的 QString 对象。
    • 示例:
    QString str = "apple banana cherry";
    QString replacedStr = str.replace("a", "X");
    
    // 输出结果: "Xpple bXnXnX cherry"
    qDebug() << replacedStr;
    ```
    
    

这两个函数都能执行字符串的替换操作,但 replaceInStrings() 是在 QStringList 对象的每个字符串中进行替换,而 replace() 是在单个字符串中进行替换。你可以根据自己的需求选择使用哪个函数。

1.8.一些常用方法和操作

QStringList是Qt框架中的一个类,用于存储字符串列表。它提供了一组方法和操作,方便对字符串列表进行处理、访问和修改。

以下是QStringList类的一些常用方法和操作的详细解释:

1. 构造函数和赋值操作符:

  • QStringList():默认构造函数,创建一个空的字符串列表。
  • QStringList(const QStringList &other):拷贝构造函数,使用另一个字符串列表初始化当前列表。
  • QStringList &operator=(const QStringList &other):赋值操作符,将另一个字符串列表赋值给当前列表。

2. 添加和移除元素:

  • void append(const QString &str):向列表末尾添加一个字符串。
  • void prepend(const QString &str):向列表开头添加一个字符串。
  • void insert(int i, const QString &str):在指定位置插入一个字符串。
  • void removeAt(int i):移除指定位置的字符串。
  • void removeOne(const QString &str):移除第一个匹配给定字符串的元素。
  • void removeAll(const QString &str):移除所有匹配给定字符串的元素。
  • void clear():清空列表,移除所有元素。

3. 获取和修改元素:

  • int size() const:返回列表中元素的数量。
  • bool isEmpty() const:检查列表是否为空。
  • QString at(int i) const:返回指定位置的字符串。
  • QString &operator[](int i):访问指定位置的字符串,可用于修改该元素。
  • const QString &operator[](int i) const:以只读方式访问指定位置的字符串。
  • QStringList mid(int pos, int length = -1) const:返回从指定位置开始的指定长度子列表。
  • QStringList &replace(int i, const QString &str):将指定位置的字符串替换为给定字符串。
  • QStringList &replace(const QString &before, const QString &after):将所有匹配给定字符串的元素替换为新的字符串。

4. 其他常用方法:

  • bool contains(const QString &str) const:检查列表中是否包含给定字符串。
  • int indexOf(const QString &str, int from = 0) const:返回第一个匹配给定字符串的位置。
  • int lastIndexOf(const QString &str, int from = -1) const:返回最后一个匹配给定字符串的位置。
  • QString join(const QString &separator) const:将列表中的所有元素连接为一个字符串,使用给定的分隔符分隔。

QStringList提供了方便的方法来处理字符串列表,如添加、移除、访问和修改元素等。它在Qt中广泛用于处理和操作字符串集合的场景,例如配置文件解析、日志记录、命令行参数处理等。

1.9.QStringList和QList关系

QStringListQList<QString> 都是Qt中用于存储字符串的容器类,但它们在实现和使用上有一些区别。

  1. 类型差异:

    • QStringList 是一个专门用于存储字符串的类,是 QString 类的派生类,可以直接使用 QString 的成员函数。
    • QList<QString> 是一个通用的列表类,可以存储任意类型的元素,其中的元素类型指定为 QString
  2. 头文件和命名空间:

    • QStringList 类定义在 <QStringList> 头文件中,属于 Qt 命名空间。
    • QList<QString> 类定义在 <QList> 头文件中,同样属于 Qt 命名空间。
  3. 成员函数和使用:

    • QStringList 类提供了一些特定于字符串列表的成员函数,如 join()split()contains() 等。
    • QList<QString> 类提供了通用的列表操作函数,如 append()insert()remove() 等。
    • 由于 QStringListQString 的派生类,可以直接使用 QString 类的成员函数。
  4. 隐式转换:

    • QStringList 对象可以隐式转换为 QList<QString> 对象,即可以将 QStringList 类型的对象赋值给 QList<QString> 类型的变量。
    • QList<QString> 对象不能隐式转换为 QStringList 对象。

在实践中,QStringList 通常用于处理字符串的特定需求,如字符串的拆分和合并,而 QList<QString> 则更通用,适用于任意类型的元素的存储和操作。如果你只需要存储字符串,推荐使用 QStringList,如果需要存储其他类型的元素,可以使用 QList

2.0.QStringList的append(),append(),operator+()

在Qt中,QStringList 提供了几种方法来添加和组合字符串:

  1. append(const QString& str):该函数用于将指定的字符串添加到 QStringList 的末尾。例如:
QStringList stringList;
stringList.append("Apple");
stringList.append("Banana");

在上述示例中,我们使用 append() 函数将字符串 “Apple” 和 “Banana” 添加到 stringList 中。

  1. operator<<(const QString& str):该运算符重载函数也可以用于将字符串添加到 QStringList 的末尾。例如:
QStringList stringList;
stringList << "Apple" << "Banana";

这个运算符的使用方式类似于使用 append() 函数。

  1. operator+(const QStringList& other):该运算符重载函数用于将两个 QStringList 进行连接。它会返回一个新的 QStringList,包含两个操作数的所有元素。例如:
QStringList list1;
list1 << "Apple" << "Banana";

QStringList list2;
list2 << "Cherry" << "Durian";

QStringList combinedList = list1 + list2;

在上述示例中,我们使用 operator+() 运算符将 list1list2 进行连接,得到一个新的 combinedList,其中包含所有元素。

需要注意的是,operator+() 运算符返回的是一个新的 QStringList,原始的操作数 list1list2 不会被修改。

这些函数和运算符提供了不同的方式来添加和组合字符串,可以根据具体的需求选择使用哪种方式。

2.1.QStringLis:Public Functions

QStringList(const QString &str)
QStringList(const QList<QString> &other)
QStringList(QList<QString> &&other)
bool	contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
bool	contains(QLatin1StringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
bool	contains(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
QStringList	filter(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
QStringList	filter(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
QStringList	filter(const QRegularExpression &re) const
qsizetype	indexOf(const QRegularExpression &re, qsizetype from = 0) const
QString	join(const QString &separator) const
QString	join(QStringView separator) const
QString	join(QLatin1StringView separator) const
QString	join(QChar separator) const
qsizetype	lastIndexOf(const QRegularExpression &re, qsizetype from = -1) const
qsizetype	removeDuplicates()
QStringList &	replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
QStringList &	replaceInStrings(QStringView before, QStringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
QStringList &	replaceInStrings(const QString &before, QStringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
QStringList &	replaceInStrings(QStringView before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive)
QStringList &	replaceInStrings(const QRegularExpression &re, const QString &after)
void	sort(Qt::CaseSensitivity cs = Qt::CaseSensitive)
QStringList	operator+(const QStringList &other) const
QStringList &	operator<<(const QString &str)
QStringList &	operator<<(const QStringList &other)
QStringList &	operator<<(const QList<QString> &other)
QStringList &	operator=(const QList<QString> &other)
QStringList &	operator=(QList<QString> &&other)

2.2.QStringLis:List of all members, including inherited members

class const_iterator
class iterator
ConstIterator
Iterator
const_pointer
const_reference
const_reverse_iterator
difference_type
parameter_type
pointer
reference
reverse_iterator
rvalue_ref
size_type
value_type
QStringList(const QString &)
QStringList(const QList<QString> &)
QStringList(QList<QString> &&)
append(QList::parameter_type)
append(QList::rvalue_ref)
append(const QList<T> &)
append(QList<T> &&)
assign(qsizetype, QList::parameter_type) : QList<T> &
assign(InputIterator, InputIterator) : QList<T> &
assign(std::initializer_list<T>) : QList<T> &
at(qsizetype) const : QList::const_reference
back() : QList::reference
back() const : QList::const_reference
begin() : QList::iterator
begin() const : QList::const_iterator
capacity() const : qsizetype
cbegin() const : QList::const_iterator
cend() const : QList::const_iterator
clear()
constBegin() const : QList::const_iterator
constData() const : QList::const_pointer
constEnd() const : QList::const_iterator
constFirst() const : const T &
constLast() const : const T &
contains(const QString &, Qt::CaseSensitivity) const : bool
contains(const AT &) const : bool
contains(QLatin1StringView, Qt::CaseSensitivity) const : bool
contains(QStringView, Qt::CaseSensitivity) const : bool
count(const AT &) const : qsizetype
count() const : qsizetype
crbegin() const : QList::const_reverse_iterator
crend() const : QList::const_reverse_iterator
data() : QList::pointer
data() const : QList::const_pointer
emplace(qsizetype, Args &&...) : QList::iterator
emplace(QList::const_iterator, Args &&...) : QList::iterator
emplaceBack(Args &&...) : QList::reference
emplace_back(Args &&...) : QList::reference
empty() const : bool
end() : QList::iterator
end() const : QList::const_iterator
endsWith(QList::parameter_type) const : bool
erase(QList::const_iterator) : QList::iterator
erase(QList::const_iterator, QList::const_iterator) : QList::iterator
fill(QList::parameter_type, qsizetype) : QList<T> &
filter(const QString &, Qt::CaseSensitivity) const : QStringList
filter(QStringView, Qt::CaseSensitivity) const : QStringList
filter(const QRegularExpression &) const : QStringList
first() : T &
first() const : const T &
first(qsizetype) const : QList<T>
front() : QList::reference
front() const : QList::const_reference
indexOf(const AT &, qsizetype) const : qsizetype
indexOf(const QRegularExpression &, qsizetype) const : qsizetype
insert(qsizetype, QList::parameter_type) : QList::iterator
insert(qsizetype, qsizetype, QList::parameter_type) : QList::iterator
insert(QList::const_iterator, QList::parameter_type) : QList::iterator
insert(QList::const_iterator, qsizetype, QList::parameter_type) : QList::iterator
insert(QList::const_iterator, QList::rvalue_ref) : QList::iterator
insert(qsizetype, QList::rvalue_ref) : QList::iterator
isEmpty() const : bool
join(const QString &) const : QString
join(QStringView) const : QString
join(QLatin1StringView) const : QString
join(QChar) const : QString
last() : T &
last() const : const T &
last(qsizetype) const : QList<T>
lastIndexOf(const AT &, qsizetype) const : qsizetype
lastIndexOf(const QRegularExpression &, qsizetype) const : qsizetype
length() const : qsizetype
mid(qsizetype, qsizetype) const : QList<T>
move(qsizetype, qsizetype)
pop_back()
pop_front()
prepend(QList::rvalue_ref)
prepend(QList::parameter_type)
push_back(QList::parameter_type)
push_back(QList::rvalue_ref)
push_front(QList::rvalue_ref)
push_front(QList::parameter_type)
rbegin() : QList::reverse_iterator
rbegin() const : QList::const_reverse_iterator
remove(qsizetype, qsizetype)
removeAll(const AT &) : qsizetype
removeAt(qsizetype)
removeDuplicates() : qsizetype
removeFirst()
removeIf(Predicate) : qsizetype
removeLast()
removeOne(const AT &) : bool
rend() : QList::reverse_iterator
rend() const : QList::const_reverse_iterator
replace(qsizetype, QList::parameter_type)
replace(qsizetype, QList::rvalue_ref)
replaceInStrings(const QString &, const QString &, Qt::CaseSensitivity) : QStringList &
replaceInStrings(QStringView, QStringView, Qt::CaseSensitivity) : QStringList &
replaceInStrings(const QString &, QStringView, Qt::CaseSensitivity) : QStringList &
replaceInStrings(QStringView, const QString &, Qt::CaseSensitivity) : QStringList &
replaceInStrings(const QRegularExpression &, const QString &) : QStringList &
reserve(qsizetype)
resize(qsizetype)
resize(qsizetype, QList::parameter_type)
shrink_to_fit()
size() const : qsizetype
sliced(qsizetype, qsizetype) const : QList<T>
sliced(qsizetype) const : QList<T>
sort(Qt::CaseSensitivity)
squeeze()
startsWith(QList::parameter_type) const : bool
swap(QList<T> &)
swapItemsAt(qsizetype, qsizetype)
takeAt(qsizetype) : T
takeFirst() : QList::value_type
takeLast() : QList::value_type
value(qsizetype) const : T
value(qsizetype, QList::parameter_type) const : T
operator!=(const QList<T> &) const : bool
operator+(const QStringList &) const : QStringList
operator+(const QList<T> &) const : QList<T>
operator+(const QList<T> &) : QList<T>
operator+(QList<T> &&) const : QList<T>
operator+(QList<T> &&) : QList<T>
operator+=(const QList<T> &) : QList<T> &
operator+=(QList<T> &&) : QList<T> &
operator+=(QList::parameter_type) : QList<T> &
operator+=(QList::rvalue_ref) : QList<T> &
operator<(const QList<T> &) const : bool
operator<<(const QString &) : QStringList &
operator<<(QList::parameter_type) : QList<T> &
operator<<(const QStringList &) : QStringList &
operator<<(const QList<T> &) : QList<T> &
operator<<(const QList<QString> &) : QStringList &
operator<<(QList<T> &&) : QList<T> &
operator<<(QList::rvalue_ref) : QList<T> &
operator<=(const QList<T> &) const : bool
operator=(const QList<QString> &) : QStringList &
operator=(std::initializer_list<T>) : QList<T> &
operator=(QList<QString> &&) : QStringList &
operator=(const QList<T> &) : QList<T> &
operator=(QList<T> &&) : QList<T> &
operator==(const QList<T> &) const : bool
operator>(const QList<T> &) const : bool
operator>=(const QList<T> &) const : bool
operator[](qsizetype) : QList::reference
operator[](qsizetype) const : QList::const_reference

2.3.Classes for String Data(Qt中字符串数据的类)

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/214952.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

设置WPF启动画面

WPF启动时间比较长&#xff0c;总让人觉得程序好像没有启动起来&#xff0c;所以想设置一个启动画面 发现WPF设置启动画面竟然如此的简单 第一步将图片放置在主工程目录下&#xff0c;如下图 第二步 将图片生成属性设置为SplashScreen即可 第三步 启动项目你就看到效果了

C++:异常

文章目录 传统的处理错误的方式C异常C异常的使用抛异常的举例异常的重新抛出异常规范 自定义异常体系C标准库中的异常体系异常的优缺点 本篇总结的是C中关于异常的内容 传统的处理错误的方式 在C语言中&#xff0c;对于传统的错误方式有 终止程序&#xff1a;例如assert&…

linux创建分区

6.2.4 创建分区&#xff1a;MBR 将房子分成小房间&#xff0c;如卧室等。 6.2.4.1 fdisk 创建和维护分区表的程序。 fdisk命令的基本语法如下&#xff1a; fdisk [必要参数][选择参数] 参数说明&#xff1a; 必要参数 -l 列出素所有分区表 -u 与 -l搭配使用&#xff0c…

什么?居然可以免费使用Jetbrains?!

JetBrains是一家捷克的软件开发公司&#xff0c;该公司位于捷克的布拉格&#xff0c;并在俄罗斯的圣彼得堡及美国麻州波士顿都设有办公室&#xff0c;该公司最为人所熟知的产品是Java编程语言开发撰写时所用的集成开发环境&#xff1a;IntelliJ IDEA。 如下是jetbrains旗下的产…

销帮帮如何和金蝶云星空对接

销帮帮介绍 销帮帮平台是一款以客户关系管理为基础&#xff0c;集团队协作、营销推广、数据分析于一体的SAAS型企业管理平台。其开放API接口包括用户认证、客户信息、用户任务、销售记录、事务记录等&#xff0c;可方便企业对平台的二次开发和集成。在应用方面&#xff0c;销帮…

设计简单高效的短链系统

目录 引言 1. 短链系统的原理 1.1 长链接生成短码 1.2 短码映射到长链接 1.3 短码重定向 1.4 过期短 URL 清理 2. 设计与实现 2.1 数据存储 2.2 短码生成 2.3 接口设计 2.4 安全性考虑 2.5 访问性能优化 引言 在当今数字化时代&#xff0c;人们对信息的分享需求不断…

树_完全二叉树的节点个数

//给你一棵 完全二叉树 的根节点 root &#xff0c;求出该树的节点个数。 // // 完全二叉树 的定义如下&#xff1a;在完全二叉树中&#xff0c;除了最底层节点可能没填满外&#xff0c;其余每层节点数都达到最大值&#xff0c;并且最下面一层的节点都集中在该层最左边的若干位…

Windows下安全认证机制

NTLM&#xff08;NT LAN Manager&#xff09; NTLM协议是在Microsoft环境中使用的一种身份验证协议&#xff0c;它允许用户向服务器证明自己是谁&#xff08;挑战&#xff08;Chalenge&#xff09;/响应&#xff08;Response&#xff09;认证机制&#xff09;&#xff0c;以便…

解密Android动态权限:保护用户隐私与应用安全的关键一步

解密Android动态权限&#xff1a;保护用户隐私与应用安全的关键一步 引言 在Android系统中&#xff0c;权限机制是保护用户隐私和应用安全的重要组成部分。Android应用需要获取一些敏感信息或执行某些敏感操作时&#xff0c;必须先获取相应的权限。例如&#xff0c;应用需要访…

普通策略梯度算法原理及PyTorch实现【VPG】

有没有想过强化学习 (RL) 是如何工作的&#xff1f; 在本文中&#xff0c;我们将从头开始构建最简单的强化学习形式之一 —普通策略梯度&#xff08;VPG&#xff09;算法。 然后&#xff0c;我们将训练它完成著名的 CartPole 挑战 — 学习从左向右移动购物车以平衡杆子。 在此…

正则表达式从放弃到入门(2):grep命令详解

正则表达式从放弃到入门&#xff08;2&#xff09;&#xff1a;grep命令详解 总结 本博文转载自 这是一篇”正则表达式”扫盲贴&#xff0c;如果你还不理解什么是正则表达式&#xff0c;看这篇文章就对了。 如果你是一个新手&#xff0c;请从头阅读这篇文章&#xff0c;如果你…

苹果配件妙控鼠标、键盘、触控板值得入手吗

大家好&#xff0c;我是极智视界&#xff0c;欢迎关注我的公众号&#xff0c;获取我的更多前沿科技分享 邀您加入我的知识星球「极智视界」&#xff0c;星球内有超多好玩的项目实战源码和资源下载&#xff0c;链接&#xff1a;https://t.zsxq.com/0aiNxERDq 苹果的优质和成功绝…

[进程控制]模拟实现命令行解释器shell

文章目录 1.字符串切割函数2.chdir()接口3.模拟实现shell 1.字符串切割函数 2.chdir()接口 3.模拟实现shell 模拟实现的shell下删除: ctrlbackspace模拟实现下table/上下左右箭头无法使用[demo] #include <stdio.h> #include <stdlib.h> #include <string.h&g…

高级开发实战MySQL、Redis、MongoDB 数据库,让你一课掌握核心技能

在现代软件开发中&#xff0c;数据库是不可或缺的一部分。MySQL、Redis和MongoDB作为三种常见的数据库系统&#xff0c;具有各自独特的特点和优势&#xff0c;对于高级开发者来说&#xff0c;掌握这三种数据库的核心技能至关重要。本文将带您通过实战的方式&#xff0c;学习如何…

pybind11教程

pybind11教程 文章目录 pybind11教程1. pybind11简介2. cmake使用pybind11教程3. pybind11的历史 1. pybind11简介 项目的GitHub地址为&#xff1a; pybind11 pybind11 是一个轻量级的头文件库&#xff0c;用于在 Python 和 C 之间进行互操作。它允许 C 代码被 Python 调用&am…

22、为什么是卷积?

(本文已加入“计算机视觉入门与调优”专栏,点击专栏查看更多文章信息) 我们先看一看神经网络(或者叫一个AI模型),是如何完成一张图片的推理的。 你肯定听说过阿尔法狗大战柯洁的故事,当时新闻一出,不知大家什么反应,反正我是被震撼到了。机器竟然学到了那么多的棋谱,…

OpenAI发生的大事件总结!

在 11 月的最后一天&#xff0c;OpenAI 官网发布了一则公告&#xff0c;宣布 Sam Altman 再次担任首席执行官&#xff0c;并成立了新的初始董事会。这项持续了 12 天的事件终于得到了解决&#xff0c;OpenAI 回到了正常运营轨道上。 一切仍然保持不变&#xff1a; Sam Altman仍…

免费分享一套开源SpringCloud支持全套二轮四轮全套源码支持云快充1.5、云快充1.6

文章目录 一、产品功能部分截图1.手机端&#xff08;小程序、安卓、ios&#xff09;2.PC端 二、小程序体验账号以及PC后台体验账号1.小程序体验账号2.PC后台体验账号关注公众号获取最新资讯 三、产品简介&#xff1f;1. 充电桩云平台&#xff08;含硬件充电桩&#xff09;&…

若依框架分页

文章目录 一、分页功能解析1.前端代码分析2.后端代码分析3. LIMIT含义 二、自定义MyPage,多态获取total1.定义MyPage类和对应的调用方法 一、分页功能解析 1.前端代码分析 页面代码 封装的api请求 接口请求 2.后端代码分析 controller代码 - startPage() getDataTable(…

编程中常见的技术难题有哪些?By AI

编程对于现代社会发展的重要性 编程&#xff0c;即按照特定的规则和逻辑&#xff0c;为计算机设计指令的过程&#xff0c;已经深深地融入现代社会的各个角落。它对人们的生活、工作和科技发展产生了深远的影响。 首先&#xff0c;编程改变了人们的生活方式。如今&#xff0c;…