“可序列化”类中的字段应该是瞬态的或可序列化的

2023-11-23

您好,我在声纳 lint 中收到此错误:

“可序列化”类中的字段应该是瞬态的或 可序列化为

  1. 私有最终条件 notEmpty = lock.newCondition();
  2. 私有最终条件 notFull = lock.newCondition();
  3. 私有Comparator比较器;

我的代码是:

package com.cgi.atom.common.priorityexec;

/**
 * Created by nageswararao.vesepog on 8/24/2016.
 */

import java.util.*;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

public class PriorityBlockingDeque<E>
        extends AbstractQueue<E>
        implements BlockingDeque<E>, java.io.Serializable {

    /*
     * Implemented as a navigable set protected by a
     * single lock and using conditions to manage blocking.
     */

    private final int capacity;

    private final LinkedList<E> list;
    /**
     * Main lock guarding all access
     */
    private final ReentrantLock lock = new ReentrantLock();
    /**
     * Condition for waiting takes
     */
    private final Condition  notEmpty = lock.newCondition();
    /**
     * Condition for waiting puts
     */
    private final Condition notFull = lock.newCondition();
    private  Comparator<E> comparator;

    /**
     * Creates a <tt>PriorityBlockingDeque</tt> with a capacity of
     * {@link Integer#MAX_VALUE}.
     */
    public PriorityBlockingDeque() {
        this(null, Integer.MAX_VALUE);
    }

    /**
     * Creates a <tt>PriorityBlockingDeque</tt> with the given (fixed) capacity.
     *
     * @param capacity the capacity of this deque
     * @throws IllegalArgumentException if <tt>capacity</tt> is less than 1
     */
    public PriorityBlockingDeque(int capacity) {
        this(null, capacity);
    }

    public PriorityBlockingDeque(Comparator<E> comparator, int capacity) {
        if (capacity <= 0) throw new IllegalArgumentException();
        this.capacity = capacity;
        this.list = new LinkedList<E>();
        this.comparator = comparator;
    }

    // Basic adding and removing operations, called only while holding lock

    /**
     * Adds e or returns false if full.
     *
     * @param e The element to add.
     * @return Whether adding was successful.
     */
    private boolean innerAdd(E e) {
        if (list.size() >= capacity)
            return false;

        int insertionPoint = Collections.binarySearch(list, e, comparator);
        if (insertionPoint < 0) {
            // this means the key didn't exist, so the insertion point is negative minus 1.
            insertionPoint = -insertionPoint - 1;
        }

        list.add(insertionPoint, e);
        notEmpty.signal();

        return true;
    }

    /**
     * Removes and returns first element, or null if empty.
     *
     * @return The removed element.
     */
    private E innerRemoveFirst() {
        E f = list.pollFirst();
        if (f == null)
            return null;


        notFull.signal();
        return f;
    }

    /**
     * Removes and returns last element, or null if empty.
     *
     * @return The removed element.
     */
    private E innerRemoveLast() {
        E l = list.pollLast();
        if (l == null)
            return null;

        notFull.signal();
        return l;
    }

    // BlockingDeque methods

    /**
     * @throws IllegalStateException {@inheritDoc}
     * @throws NullPointerException  {@inheritDoc}
     */
    public void addFirst(E e) {
        if (!offerFirst(e))
            throw new IllegalStateException("Deque full");
    }

    /**
     * @throws IllegalStateException {@inheritDoc}
     * @throws NullPointerException  {@inheritDoc}
     */
    public void addLast(E e) {
        if (!offerLast(e))
            throw new IllegalStateException("Deque full");
    }

    /**
     * @throws NullPointerException {@inheritDoc}
     */
    public boolean offerFirst(E e) {
        if (e == null) throw new NullPointerException();
        lock.lock();
        try {
            return innerAdd(e);
        } finally {
            lock.unlock();
        }
    }

    /**
     * @throws NullPointerException {@inheritDoc}
     */
    public boolean offerLast(E e) {
        if (e == null) throw new NullPointerException();
        lock.lock();
        try {
            return innerAdd(e);
        } finally {
            lock.unlock();
        }
    }

    /**
     * @throws NullPointerException {@inheritDoc}
     * @throws InterruptedException {@inheritDoc}
     */
    public void putFirst(E e) throws InterruptedException {
        if (e == null) throw new NullPointerException();
        lock.lock();
        try {
            while (!innerAdd(e))
                notFull.await();
        } finally {
            lock.unlock();
        }
    }

    /**
     * @throws NullPointerException {@inheritDoc}
     * @throws InterruptedException {@inheritDoc}
     */
    public void putLast(E e) throws InterruptedException {
        if (e == null) throw new NullPointerException();
        lock.lock();
        try {
            while (!innerAdd(e))
                notFull.await();
        } finally {
            lock.unlock();
        }
    }

    /**
     * @throws NullPointerException {@inheritDoc}
     * @throws InterruptedException {@inheritDoc}
     */
    public boolean offerFirst(E e, long timeout, TimeUnit unit)
            throws InterruptedException {
        if (e == null) throw new NullPointerException();
        long nanos = unit.toNanos(timeout);
        lock.lockInterruptibly();
        try {
            for (; ;) {
                if (innerAdd(e))
                    return true;
                if (nanos <= 0)
                    return false;
                nanos = notFull.awaitNanos(nanos);
            }
        } finally {
            lock.unlock();
        }
    }

    /**
     * @throws NullPointerException {@inheritDoc}
     * @throws InterruptedException {@inheritDoc}
     */
    public boolean offerLast(E e, long timeout, TimeUnit unit)
            throws InterruptedException {
        if (e == null) throw new NullPointerException();
        long nanos = unit.toNanos(timeout);
        lock.lockInterruptibly();
        try {
            for (; ;) {
                if (innerAdd(e))
                    return true;
                if (nanos <= 0)
                    return false;
                nanos = notFull.awaitNanos(nanos);
            }
        } finally {
            lock.unlock();
        }
    }

    /**
     * @throws NoSuchElementException {@inheritDoc}
     */
    public E removeFirst() {
        E x = pollFirst();
        if (x == null) throw new NoSuchElementException();
        return x;
    }

    /**
     * @throws NoSuchElementException {@inheritDoc}
     */
    public E removeLast() {
        E x = pollLast();
        if (x == null) throw new NoSuchElementException();
        return x;
    }

    public E pollFirst() {
        lock.lock();
        try {
            return innerRemoveFirst();
        } finally {
            lock.unlock();
        }
    }

    public E pollLast() {
        lock.lock();
        try {
            return innerRemoveLast();
        } finally {
            lock.unlock();
        }
    }

    public E takeFirst() throws InterruptedException {
        lock.lock();
        try {
            E x;
            while ((x = innerRemoveFirst()) == null)
                notEmpty.await();
            return x;
        } finally {
            lock.unlock();
        }
    }

    public E takeLast() throws InterruptedException {
        lock.lock();
        try {
            E x;
            while ((x = innerRemoveLast()) == null)
                notEmpty.await();
            return x;
        } finally {
            lock.unlock();
        }
    }

    public E pollFirst(long timeout, TimeUnit unit)
            throws InterruptedException {
        long nanos = unit.toNanos(timeout);
        lock.lockInterruptibly();
        try {
            for (; ;) {
                E x = innerRemoveFirst();
                if (x != null)
                    return x;
                if (nanos <= 0)
                    return null;
                nanos = notEmpty.awaitNanos(nanos);
            }
        } finally {
            lock.unlock();
        }
    }

    public E pollLast(long timeout, TimeUnit unit)
            throws InterruptedException {
        long nanos = unit.toNanos(timeout);
        lock.lockInterruptibly();
        try {
            for (; ;) {
                E x = innerRemoveLast();
                if (x != null)
                    return x;
                if (nanos <= 0)
                    return null;
                nanos = notEmpty.awaitNanos(nanos);
            }
        } finally {
            lock.unlock();
        }
    }

    /**
     * @throws NoSuchElementException {@inheritDoc}
     */
    public E getFirst() {
        E x = peekFirst();
        if (x == null) throw new NoSuchElementException();
        return x;
    }

    /**
     * @throws NoSuchElementException {@inheritDoc}
     */
    public E getLast() {
        E x = peekLast();
        if (x == null) throw new NoSuchElementException();
        return x;
    }

    public E peekFirst() {
        lock.lock();
        try {
            return list.size() == 0 ? null : list.peekFirst();
        } finally {
            lock.unlock();
        }
    }

    public E peekLast() {
        lock.lock();
        try {
            return list.size() == 0 ? null : list.peekLast();
        } finally {
            lock.unlock();
        }
    }

    public boolean removeFirstOccurrence(Object o) {
        if (o == null) return false;
        lock.lock();
        try {
            for (Iterator<E> it = list.iterator(); it.hasNext();) {
                E e = it.next();
                if (o.equals(e)) {
                    it.remove();
                    return true;
                }
            }
            return false;
        } finally {
            lock.unlock();
        }
    }

    public boolean removeLastOccurrence(Object o) {
        if (o == null) return false;
        lock.lock();
        try {
            for (Iterator<E> it = list.descendingIterator(); it.hasNext();) {
                E e = it.next();
                if (o.equals(e)) {
                    it.remove();
                    return true;
                }
            }
            return false;
        } finally {
            lock.unlock();
        }
    }

    // BlockingQueue methods

    /**
     * Inserts the specified element to the deque unless it would
     * violate capacity restrictions.  When using a capacity-restricted deque,
     * it is generally preferable to use method {@link #offer(Object) offer}.
     * <p/>
     * <p>This method is equivalent to {@link #addLast}.
     *
     * @throws IllegalStateException if the element cannot be added at this
     *                               time due to capacity restrictions
     * @throws NullPointerException  if the specified element is null
     */
    @Override
    public boolean add(E e) {
        addLast(e);
        return true;
    }

    /**
     * @throws NullPointerException if the specified element is null
     */
    public boolean offer(E e) {
        return offerLast(e);
    }

    /**
     * @throws NullPointerException {@inheritDoc}
     * @throws InterruptedException {@inheritDoc}
     */
    public void put(E e) throws InterruptedException {
        putLast(e);
    }

    /**
     * @throws NullPointerException {@inheritDoc}
     * @throws InterruptedException {@inheritDoc}
     */
    public boolean offer(E e, long timeout, TimeUnit unit)
            throws InterruptedException {
        return offerLast(e, timeout, unit);
    }

    /**
     * Retrieves and removes the head of the queue represented by this deque.
     * This method differs from {@link #poll poll} only in that it throws an
     * exception if this deque is empty.
     * <p/>
     * <p>This method is equivalent to {@link #removeFirst() removeFirst}.
     *
     * @return the head of the queue represented by this deque
     * @throws NoSuchElementException if this deque is empty
     */
    @Override
    public E remove() {
        return removeFirst();
    }

    public E poll() {
        return pollFirst();
    }

    public E take() throws InterruptedException {
        return takeFirst();
    }

    public E poll(long timeout, TimeUnit unit) throws InterruptedException {
        return pollFirst(timeout, unit);
    }

    /**
     * Retrieves, but does not remove, the head of the queue represented by
     * this deque.  This method differs from {@link #peek peek} only in that
     * it throws an exception if this deque is empty.
     * <p/>
     * <p>This method is equivalent to {@link #getFirst() getFirst}.
     *
     * @return the head of the queue represented by this deque
     * @throws NoSuchElementException if this deque is empty
     */
    @Override
    public E element() {
        return getFirst();
    }

    public E peek() {
        return peekFirst();
    }

    /**
     * Returns the number of additional elements that this deque can ideally
     * (in the absence of memory or resource constraints) accept without
     * blocking. This is always equal to the initial capacity of this deque
     * less the current <tt>size</tt> of this deque.
     * <p/>
     * <p>Note that you <em>cannot</em> always tell if an attempt to insert
     * an element will succeed by inspecting <tt>remainingCapacity</tt>
     * because it may be the case that another thread is about to
     * insert or remove an element.
     */
    public int remainingCapacity() {
        lock.lock();
        try {
            return capacity - list.size();
        } finally {
            lock.unlock();
        }
    }

    /**
     * @throws UnsupportedOperationException {@inheritDoc}
     * @throws ClassCastException            {@inheritDoc}
     * @throws NullPointerException          {@inheritDoc}
     * @throws IllegalArgumentException      {@inheritDoc}
     */
    public int drainTo(Collection<? super E> c) {
        if (c==null)
            throw new NullPointerException();
        if (c.equals(this))
            throw new IllegalArgumentException();
        lock.lock();
        try {
            for (E e : list) {
                c.add(e);
            }
            int n = list.size();
            list.clear();
            notFull.signalAll();
            return n;
        } finally {
            lock.unlock();
        }
    }

    /**
     * @throws UnsupportedOperationException {@inheritDoc}
     * @throws ClassCastException            {@inheritDoc}
     * @throws NullPointerException          {@inheritDoc}
     * @throws IllegalArgumentException      {@inheritDoc}
     */
    public int drainTo(Collection<? super E> c, int maxElements) {
        if (c ==null)
            throw new NullPointerException();
        if (c.equals(this))
            throw new IllegalArgumentException();
        lock.lock();
        try {
            int n = 0;
            for (Iterator<E> it = list.iterator(); n < maxElements && it.hasNext();) {
                E e = it.next();
                c.add(e);
                it.remove();
                ++n;
            }

            notFull.signalAll();
            return n;
        } finally {
            lock.unlock();
        }
    }

    // Stack methods

    /**
     * @throws IllegalStateException {@inheritDoc}
     * @throws NullPointerException  {@inheritDoc}
     */
    public void push(E e) {
        addFirst(e);
    }

    /**
     * @throws NoSuchElementException {@inheritDoc}
     */
    public E pop() {
        return removeFirst();
    }

    // Collection methods

    /**
     * Removes the first occurrence of the specified element from this deque.
     * If the deque does not contain the element, it is unchanged.
     * More formally, removes the first element <tt>e</tt> such that
     * <tt>o.equals(e)</tt> (if such an element exists).
     * Returns <tt>true</tt> if this deque contained the specified element
     * (or equivalently, if this deque changed as a result of the call).
     * <p/>
     * <p>This method is equivalent to
     * {@link #removeFirstOccurrence(Object) removeFirstOccurrence}.
     *
     * @param o element to be removed from this deque, if present
     * @return <tt>true</tt> if this deque changed as a result of the call
     */
    @Override
    public boolean remove(Object o) {
        return removeFirstOccurrence(o);
    }

    /**
     * Returns the number of elements in this deque.
     *
     * @return the number of elements in this deque
     */
    @Override
    public int size() {
        lock.lock();
        try {
            return list.size();
        } finally {
            lock.unlock();
        }
    }

    /**
     * Returns <tt>true</tt> if this deque contains the specified element.
     * More formally, returns <tt>true</tt> if and only if this deque contains
     * at least one element <tt>e</tt> such that <tt>o.equals(e)</tt>.
     *
     * @param o object to be checked for containment in this deque
     * @return <tt>true</tt> if this deque contains the specified element
     */
    @Override
    public boolean contains(Object o) {
        if (o == null) return false;
        lock.lock();
        try {
            return list.contains(o);
        } finally {
            lock.unlock();
        }
    }

    /**
     * Returns an array containing all of the elements in this deque, in
     * proper sequence (from first to last element).
     * <p/>
     * <p>The returned array will be "safe" in that no references to it are
     * maintained by this deque.  (In other words, this method must allocate
     * a new array).  The caller is thus free to modify the returned array.
     * <p/>
     * <p>This method acts as bridge between array-based and collection-based
     * APIs.
     *
     * @return an array containing all of the elements in this deque
     */
    @Override
    public Object[] toArray() {
        lock.lock();
        try {
            return list.toArray();
        } finally {
            lock.unlock();
        }
    }

    /**
     * Returns an array containing all of the elements in this deque, in
     * proper sequence; the runtime type of the returned array is that of
     * the specified array.  If the deque fits in the specified array, it
     * is returned therein.  Otherwise, a new array is allocated with the
     * runtime type of the specified array and the size of this deque.
     * <p/>
     * <p>If this deque fits in the specified array with room to spare
     * (i.e., the array has more elements than this deque), the element in
     * the array immediately following the end of the deque is set to
     * <tt>null</tt>.
     * <p/>
     * <p>Like the {@link #toArray()} method, this method acts as bridge between
     * array-based and collection-based APIs.  Further, this method allows
     * precise control over the runtime type of the output array, and may,
     * under certain circumstances, be used to save allocation costs.
     * <p/>
     * <p>Suppose <tt>x</tt> is a deque known to contain only strings.
     * The following code can be used to dump the deque into a newly
     * allocated array of <tt>String</tt>:
     * <p/>
     * <pre>
     *     String[] y = x.toArray(new String[0]);</pre>
     * <p/>
     * Note that <tt>toArray(new Object[0])</tt> is identical in function to
     * <tt>toArray()</tt>.
     *
     * @param a the array into which the elements of the deque are to
     *          be stored, if it is big enough; otherwise, a new array of the
     *          same runtime type is allocated for this purpose
     * @return an array containing all of the elements in this deque
     * @throws ArrayStoreException  if the runtime type of the specified array
     *                              is not a supertype of the runtime type of every element in
     *                              this deque
     * @throws NullPointerException if the specified array is null
     */
    @Override
    public <T> T[] toArray(T[] a) {
        lock.lock();
        try {
            return list.toArray(a);
        } finally {
            lock.unlock();
        }
    }

    @Override
    public String toString() {
        lock.lock();
        try {
            return super.toString();
        } finally {
            lock.unlock();
        }
    }

    /**
     * Atomically removes all of the elements from this deque.
     * The deque will be empty after this call returns.
     */
    @Override
    public void clear() {
        lock.lock();
        try {
            list.clear();
            notFull.signalAll();
        } finally {
            lock.unlock();
        }
    }

    @Override
    public Iterator<E> iterator() {
        return list.iterator();
    }

    public Iterator<E> descendingIterator() {
        return list.descendingIterator();
    }
}

有人可以提供解决方案,以便声纳不会显示所有三个变量的这些错误吗?


声纳有已经给你了两个解决方案。

  1. 使它们可序列化
  2. 让它们变得短暂

您不能执行前者,因为它们不是您编写的类,因此您需要使它们成为瞬态的。看:Java 中的关键字“transient”是什么意思?

或者,如果您不需要序列化任何PriorityBlockingDeque然后删除该接口即可。

这是一个警告的原因是因为应该如何序列化包含不可序列化组件的类?

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

“可序列化”类中的字段应该是瞬态的或可序列化的 的相关文章

  • 菜单未显示在应用程序中

    由于某种原因 我的操作菜单在我的 Android Studio 应用程序中消失了 我正在按照教程学习如何创建 Android 应用程序 但最终遇到了这个问题 我正在使用 atm 的教程 http www raywenderlich com
  • Java 中的 XPath 节点集

    我在 eclipse 中有这段代码 NodeSet nodes NodeSet xPath evaluate expression inputSource XPathConstants NODESET 它给我 NodeSet 上的编译时错误
  • 如何在 JFace 的 TableViewer 中创建复选框?

    我创建了一个包含两列的 tableViewer 我想将其中一列设为复选框 为此 我创建了一个 CheckBoxCellEditor 但我不知道为什么它不起作用 名为 tableName 的列显示其值正常 色谱柱规格如下 String COL
  • ElasticBeanstalk Java,Spring 活动配置文件

    我正在尝试通过 AWS ElasticBeanstalk 启动 spring boot jar 一切正常 配置文件为 默认 有谁知道如何为 java ElasticBeanstalk 应用程序 不是 tomcat 设置活动配置文件 spri
  • 在浏览器中点击应用程序时播放框架挂起

    我正在 Play 中运行一个应用程序activator run 也许 5 次中有 3 次 它会挂起 当我去http localhost 9000 它就永远坐在那里旋转 我看到很多promise timed out错误也 我应该去哪里寻找这个
  • Convert.FromBase64String 方法的 Java 等效项

    Java 中是否有相当于Convert FromBase64String http msdn microsoft com en us library system convert frombase64string aspx which 将指
  • Prim 的迷宫生成算法:获取相邻单元格

    我基于 Prim 算法编写了一个迷宫生成器程序 该算法是 Prim 算法的随机版本 从充满墙壁的网格开始 选择一个单元格 将其标记为迷宫的一部分 将单元格的墙壁添加到墙壁列表中 While there are walls in the li
  • 无法理解 Java 地图条目集

    我正在看一个 java 刽子手游戏 https github com leleah EvilHangman blob master EvilHangman java https github com leleah EvilHangman b
  • Clip 在 Java 中播放 WAV 文件时出现严重延迟

    我编写了一段代码来读取 WAV 文件 大小约为 80 mb 并播放该文件 问题是声音播放效果很差 极度滞后 你能告诉我有什么问题吗 这是我的代码 我称之为doPlayJframe 构造函数内的函数 private void doPlay f
  • 从 android 简单上传到 S3

    我在网上搜索了从 android 上传简单文件到 s3 的方法 但找不到任何有效的方法 我认为这是因为缺乏具体步骤 1 https mobile awsblog com post Tx1V588RKX5XPQB TransferManage
  • 制作java包

    我的 Java 类组织变得有点混乱 所以我要回顾一下我在 Java 学习中跳过的东西 类路径 我无法安静地将心爱的类编译到我为它们创建的包中 这是我的文件夹层次结构 com david Greet java greeter SayHello
  • Java直接内存:在自定义类中使用sun.misc.Cleaner

    在 Java 中 NIO 直接缓冲区分配的内存通过以下方式释放 sun misc Cleaner实例 一些比对象终结更有效的特殊幻像引用 这种清洁器机制是否仅针对直接缓冲区子类硬编码在 JVM 中 或者是否也可以在自定义组件中使用清洁器 例
  • org.jdesktop.application 包不存在

    几天以来我一直在构建一个 Java 桌面应用程序 一切都很顺利 但是今天 当我打开Netbeans并编译文件时 出现以下编译错误 Compiling 9 source files to C Documents and Settings Ad
  • Java中未绑定通配符泛型的用途和要点是什么?

    我不明白未绑定通配符泛型有什么用 具有上限的绑定通配符泛型 stuff for Object item stuff System out println item Since PrintStream println 可以处理所有引用类型 通
  • 如何在 Maven 中显示消息

    如何在 Maven 中显示消息 在ant中 我们确实有 echo 来显示消息 但是在maven中 我该怎么做呢 您可以使用 antrun 插件
  • Keycloak - 自定义 SPI 未出现在列表中

    我为我的 keycloak 服务器制作了一个自定义 SPI 现在我必须在管理控制台上配置它 我将 SPI 添加为模块 并手动安装 因此我将其放在 module package name main 中 并包含 module xml 我还将其放
  • KeyPressed 和 KeyTyped 混淆[重复]

    这个问题在这里已经有答案了 我搜索过之间的区别KeyPressedand KeyTyped事件 但我仍然不清楚 我发现的一件事是 Keypressed 比 KeyTyped 首先被触发 请澄清一下这些事件何时被准确触发 哪个适合用于哪个目的
  • javax.persistence.Table.indexes()[Ljavax/persistence/Index 中的 NoSuchMethodError

    我有一个 Play Framework 应用程序 并且我was使用 Hibernate 4 2 5 Final 通过 Maven 依赖项管理器检索 我决定升级到 Hibernate 4 3 0 Final 成功重新编译我的应用程序并运行它
  • Jackson 将单个项目反序列化到列表中

    我正在尝试使用一项服务 该服务为我提供了一个带有数组字段的实体 id 23233 items name item 1 name item 2 但是 当数组包含单个项目时 将返回该项目本身 而不是包含一个元素的数组 id 43567 item
  • Swagger/Openapi-Annotations:如何使用 $ref 生成 allOf?

    我正在生成 Rest 端点 包括添加OpenAPI Swagger对生成的代码进行注释 虽然它对于基本类型运行得很好 但我在自定义类方面遇到了一些问题 现在我有很多自定义类的重复架构条目 使用 Schema 实现 MyClass class

随机推荐

  • 为什么文本环绕浮动元素而不是像另一个 div 一样位于下方?

    我试图更深入地了解 CSS 我注意到当div漂浮在其下方的其他元素 对于环绕它的文本来说 情况并非如此 怎么会 这是设计使然 因为这就是浮动的工作原理 如果您参考文档 float CSS 属性将元素放置在其容器的左侧或右侧 允许文本和环绕它
  • 使用 Graph API v.2.0 获取 Facebook 好友 [重复]

    这个问题在这里已经有答案了 前段时间 我曾经带朋友这样使用Graph API 使用Graph API Explorer me friends 一切都很完美 但现在 在 2 0 版本中 我发现这种方式对于那些没有使用 通过 Facebook
  • 查找无向图中的所有循环

    如果我有一个无向图 如何获得所有循环的列表 例如 从下图中 我想要循环 a b d e c a b c b d e 这在多项式时间内是不可能的 如果可能的话 我们可以用它来找到所有循环 从而找到最大长度的循环 这意味着我们可以在多项式时间内
  • 如何实现Openid connect和Spring Security

    我是身份验证和授权的初学者 但我必须在工作中连接到 openid 连接提供商 我对如何使用 Spring Security 有所了解 首先 我通过遵循良好的方向获得了 UserInfo 对象 https oauthssodemo appsp
  • Rails:ParameterFilter::compiled_filter 尝试复制符号

    我正在使用 Rails 异常通知程序 gem 运行 Rails3 当发生异常并且应该发送电子邮件时 我从 ParameterFilter 类收到异常 我在 Rails 源代码中发现了问题 但不确定继续的最佳方法 问题出现在 ActionDi
  • 为什么 pandas.DataFrame.apply 打印出垃圾?

    考虑这个简单的数据框 a b 0 1 2 1 2 3 我执行一个 apply像这样 In 4 df apply lambda x x values Out 4 a 140279910807944 140279910807920 b 1402
  • .htaccess RewriteRule 保留 GET URL 参数

    我在保持 URL 参数正常工作时遇到问题 htaccess网址重写 My htaccess重写如下 RewriteEngine on RewriteRule a z 2 2 a zA Z0 9 index php lang 1 page 2
  • 尝试运行 Node.js 应用程序时如何修复“语法错误:无效或意外的令牌”

    我已经安装了Node js来自官方网站 下列的这些微软文档我尝试通过以下步骤创建我的第一个 Node js 应用程序 打开 PowerShell 并创建一个新目录 mkdir NodeApp 然后进入目录 cd NodeApp 在 VS C
  • 块的时间?

    有没有办法报告计算每个块需要多少时间 我正在努力从一些大型脚本创建一个文档 很高兴知道时间花在哪里 我确实使用了缓存功能 所以当然 一旦对象被缓存 处理文档就不会太慢 但我想隔离慢速块 看看如何阻止它们被重新计算 除非绝对需要 一种想法是
  • Android PCM 字节

    我正在使用 AudioRecord 类来分析麦克风中的原始 pcm 字节 所以这工作得很好 现在我需要将 pcm 字节转换为分贝 我有一个公式 可以将 Pa 中的声压转换为 db 分贝 20 log10 Pa 参考 Pa 所以问题是我从缓冲
  • 将 java 代码翻译成 kotlin 的最佳方法

    URL url new URL urlSpec HttpURLConnection connection HttpURLConnection url openConnection InputStream in connection getI
  • Java - 运行一个线程两次[关闭]

    Closed 这个问题不符合堆栈溢出指南 目前不接受答案 来自另一个帖子 如果一个线程需要运行多次 那么应该创建一个 Thread 的新实例并对其调用 start 这是怎么做到的 我会使用另一层抽象 使用ExecutorService 这是
  • C++ 中 C 库的范围 -

    C 编程语言 特别版 第 431 页指出 For every header lt X h gt defining part of the C standard library in the global namespace and also
  • 计算字符串出现次数并绘制直方图

    是否有任何直接的方法可以从像下面这样的元胞数组创建直方图 连续条之间的间距应该完全相同 x 轴的标签应该是垂直方向下面的变量的相应名称 w464 w462 w461 w464 w461 w463 w466 w461 我也想知道更好的方法 F
  • 主题和行为主题有什么区别?

    我不清楚 a 之间的区别Subject and a BehaviorSubject 难道只是一个BehaviorSubject有getValue 功能 行为主体持有一个值 当它被订阅时 它会立即发出该值 主题不具有值 主题示例 使用 RxJ
  • 在 Windows 上使用 mkbundle 创建 C# 可执行文件

    我正在尝试从控制台应用程序创建可执行文件 我已经安装了 mono cygwin mingw gcc mingw zlib1 mingw zlib devel pkg config 并将以下几行添加到我的 bashrc 文件中 export
  • 使用CSS和Javascript的无限旋转动画[关闭]

    Closed 这个问题需要多问focused 目前不接受答案 我浏览了一些单页网站示例并发现了这一点 http alwayscreative net 我对背景中无限旋转的圆盘感到非常惊讶 我看过一些例子 但没有一个是这样工作的 谁能告诉我这
  • 如何停止核心动画?

    我现在正在使用核心动画为按钮设置动画 在某种情况下我想停止该动画 如何停止动画 这是为按钮设置动画的方法 void animateButton UIButton btnName CABasicAnimation pulseAnimation
  • 为什么 C++ 允许未命名函数参数?

    以下是完全合法的C code void foo int cout lt lt Yo lt lt endl int main int argc char const argv foo 5 return 0 我想知道 考虑到无法从函数内部引用它
  • “可序列化”类中的字段应该是瞬态的或可序列化的

    您好 我在声纳 lint 中收到此错误 可序列化 类中的字段应该是瞬态的或 可序列化为 私有最终条件 notEmpty lock newCondition 私有最终条件 notFull lock newCondition 私有Compara