text:
package com.netease.nim.uikit.common.ui.recyclerview.adapter;

import android.animation.Animator;
import android.content.Context;
import android.support.annotation.IntDef;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.LayoutParams;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
import android.widget.FrameLayout;
import android.widget.LinearLayout;

import com.netease.nim.uikit.common.ui.recyclerview.animation.AlphaInAnimation;
import com.netease.nim.uikit.common.ui.recyclerview.animation.BaseAnimation;
import com.netease.nim.uikit.common.ui.recyclerview.animation.ScaleInAnimation;
import com.netease.nim.uikit.common.ui.recyclerview.animation.SlideInBottomAnimation;
import com.netease.nim.uikit.common.ui.recyclerview.animation.SlideInLeftAnimation;
import com.netease.nim.uikit.common.ui.recyclerview.animation.SlideInRightAnimation;
import com.netease.nim.uikit.common.ui.recyclerview.entity.IExpandable;
import com.netease.nim.uikit.common.ui.recyclerview.holder.BaseViewHolder;
import com.netease.nim.uikit.common.ui.recyclerview.loadmore.LoadMoreView;
import com.netease.nim.uikit.common.ui.recyclerview.loadmore.SimpleLoadMoreView;
import com.netease.nim.uikit.common.ui.recyclerview.util.RecyclerViewUtil;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.List;

import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;

public abstract class BaseQuickAdapter<T, K extends BaseViewHolder> extends RecyclerView.Adapter<K> implements IRecyclerView {

    private boolean isScrolling = false;

    //load more
    private boolean mNextLoadEnable = false;
    private boolean mLoadMoreEnable = false;
    private RequestLoadMoreListener mRequestLoadMoreListener;
    private boolean mLoading = false;
    private LoadMoreView mLoadMoreView = new SimpleLoadMoreView();

    private boolean mFirstOnlyEnable = true;
    private boolean mOpenAnimationEnable = false;
    private Interpolator mInterpolator = new LinearInterpolator();
    private int mDuration = 300;
    private int mLastPosition = -1;
    //@AnimationType
    private BaseAnimation mCustomAnimation;
    private BaseAnimation mSelectAnimation = new AlphaInAnimation();
    //header footer
    private LinearLayout mHeaderLayout;
    private LinearLayout mFooterLayout;
    //empty
    private FrameLayout mEmptyView;
    private boolean mIsUseEmpty = true;
    private boolean mHeadAndEmptyEnable;
    private boolean mFootAndEmptyEnable;

    protected static final String TAG = BaseQuickAdapter.class.getSimpleName();
    protected Context mContext;
    protected int mLayoutResId;
    protected LayoutInflater mLayoutInflater;
    protected List<T> mData;

    @IntDef({ALPHAIN, SCALEIN, SLIDEIN_BOTTOM, SLIDEIN_LEFT, SLIDEIN_RIGHT})
    @Retention(RetentionPolicy.SOURCE)
    public @interface AnimationType {
    }

    /**
     * Use with {@link #openLoadAnimation}
     */
    public static final int ALPHAIN = 0x00000001;
    /**
     * Use with {@link #openLoadAnimation}
     */
    public static final int SCALEIN = 0x00000002;
    /**
     * Use with {@link #openLoadAnimation}
     */
    public static final int SLIDEIN_BOTTOM = 0x00000003;
    /**
     * Use with {@link #openLoadAnimation}
     */
    public static final int SLIDEIN_LEFT = 0x00000004;
    /**
     * Use with {@link #openLoadAnimation}
     */
    public static final int SLIDEIN_RIGHT = 0x00000005;

    public void setOnLoadMoreListener(RequestLoadMoreListener requestLoadMoreListener) {
        this.mRequestLoadMoreListener = requestLoadMoreListener;
        mNextLoadEnable = true;
        mLoadMoreEnable = true;
        mLoading = false;
    }

    /**
     * Set custom load more
     *
     * @param loadingView
     */
    public void setLoadMoreView(LoadMoreView loadingView) {
        this.mLoadMoreView = loadingView;
    }

    /**
     * Load more view count
     *
     * @return 0 or 1
     */
    private int getLoadMoreViewCount() {
        if (mRequestLoadMoreListener == null || !mLoadMoreEnable) {
            return 0;
        }
        if (!mNextLoadEnable && mLoadMoreView.isLoadEndMoreGone()) {
            return 0;
        }
        if (mData.size() == 0) {
            return 0;
        }
        return 1;
    }

    /**
     * @return Whether the Adapter is actively showing load
     * progress.
     */
    public boolean isLoading() {
        return mLoading;
    }

    /**
     * Refresh end, no more data
     */
    public void loadMoreEnd() {
        loadMoreEnd(false);
    }

    /**
     * Refresh end, no more data
     *
     * @param gone if true gone the load more view
     */
    public void loadMoreEnd(boolean gone) {
        if (getLoadMoreViewCount() == 0) {
            return;
        }
        mLoading = false;
        mNextLoadEnable = false;
        mLoadMoreView.setLoadMoreEndGone(gone);
        if (gone) {
            notifyItemRemoved(getHeaderLayoutCount() + mData.size() + getFooterLayoutCount());
        } else {
            mLoadMoreView.setLoadMoreStatus(LoadMoreView.STATUS_END);
            notifyItemChanged(getHeaderLayoutCount() + mData.size() + getFooterLayoutCount());
        }
    }

    /**
     * Refresh complete
     */
    public void loadMoreComplete() {
        if (getLoadMoreViewCount() == 0) {
            return;
        }
        mLoading = false;
        mLoadMoreView.setLoadMoreStatus(LoadMoreView.STATUS_DEFAULT);
        notifyItemChanged(getHeaderLayoutCount() + mData.size() + getFooterLayoutCount());
    }

    /**
     * Refresh failed
     */
    public void loadMoreFail() {
        if (getLoadMoreViewCount() == 0) {
            return;
        }
        mLoading = false;
        mLoadMoreView.setLoadMoreStatus(LoadMoreView.STATUS_FAIL);
        notifyItemChanged(getHeaderLayoutCount() + mData.size() + getFooterLayoutCount());
    }

    /**
     * Set the enabled state of load more.
     *
     * @param enable True if load more is enabled, false otherwise.
     */
    public void setEnableLoadMore(boolean enable) {
        int oldLoadMoreCount = getLoadMoreViewCount();
        mLoadMoreEnable = enable;
        int newLoadMoreCount = getLoadMoreViewCount();

        if (oldLoadMoreCount == 1) {
            if (newLoadMoreCount == 0) {
                notifyItemRemoved(getHeaderLayoutCount() + mData.size() + getFooterLayoutCount());
            }
        } else {
            if (newLoadMoreCount == 1) {
                mLoadMoreView.setLoadMoreStatus(LoadMoreView.STATUS_DEFAULT);
                notifyItemInserted(getHeaderLayoutCount() + mData.size() + getFooterLayoutCount());
            }
        }
    }

    /**
     * Returns the enabled status for load more.
     *
     * @return True if load more is enabled, false otherwise.
     */
    public boolean isLoadMoreEnable() {
        return mLoadMoreEnable;
    }

    /**
     * Sets the duration of the animation.
     *
     * @param duration The length of the animation, in milliseconds.
     */
    public void setDuration(int duration) {
        mDuration = duration;
    }

    /**
     * Same as QuickAdapter#QuickAdapter(Context,int) but with
     * some initialization data.
     *
     * @param recyclerView RecyclerView which use this adapter
     * @param layoutResId  The layout resource id of each item.
     * @param data         A new list is created out of this one to avoid mutable list
     */
    public BaseQuickAdapter(RecyclerView recyclerView, int layoutResId, List<T> data) {
        this.mData = data == null ? new ArrayList<T>() : data;
        if (layoutResId != 0) {
            this.mLayoutResId = layoutResId;
        }

        /**
         * 在适配器中声明一个全局的boolean变量用来保存此刻是否在滚动,然后通过给RecyclerView设置滚动监听,然后在滚动监听器的onScrollStateChanged()方法中给boolean值赋值,看是否在滚动。
         * 在使用这个适配器的时候,可以根据滚动状态的不同来判断:比如正在滚动的时候就只显示内存缓存的图片,如果内存缓存中没有就显示一张默认图片;而如果没有在滚动就采用正常的图片加载方案去加载网络或者缓存中的图片。
         */
        recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                super.onScrollStateChanged(recyclerView, newState);
                isScrolling = newState != RecyclerView.SCROLL_STATE_IDLE;
            }
        });

        /**
         * 关闭默认viewholder item动画
         */
        RecyclerViewUtil.changeItemAnimation(recyclerView, false);
    }

    public BaseQuickAdapter(RecyclerView recyclerView, List<T> data) {
        this(recyclerView, 0, data);
    }

    /**
     * remove the item associated with the specified position of adapter
     *
     * @param position
     */
    public void remove(int position) {
        final T item = mData.get(position);
        mData.remove(position);
        notifyItemRemoved(position + getHeaderLayoutCount());
        onRemove(item);
    }

    protected void onRemove(T item) {

    }

    /**
     * insert  a item associated with the specified position of adapter
     *
     * @param position
     * @param item
     */
    public void add(int position, T item) {
        mData.add(position, item);
        notifyItemInserted(position + getHeaderLayoutCount());
    }

    /**
     * setting up a new instance to data;
     *
     * @param data
     */
    public void setNewData(List<T> data) {
        this.mData = data == null ? new ArrayList<T>() : data;
        if (mRequestLoadMoreListener != null) {
            mNextLoadEnable = true;
            mLoadMoreEnable = true;
            mLoading = false;
            mLoadMoreView.setLoadMoreStatus(LoadMoreView.STATUS_DEFAULT);
        }
        mLastPosition = -1;
        notifyDataSetChanged();
    }

    /**
     * clear data before reload
     */
    public void clearData() {
        this.mData.clear();
        if (mRequestLoadMoreListener != null) {
            mNextLoadEnable = true;
            mLoading = false;
            mLoadMoreView.setLoadMoreStatus(LoadMoreView.STATUS_DEFAULT);
        }
        mLastPosition = -1;
        notifyDataSetChanged();
    }

    /**
     * add one new data in to certain location
     *
     * @param position
     */
    public void addData(int position, T data) {
        if (0 <= position && position < mData.size()) {
            mData.add(position, data);
            notifyItemInserted(position + getHeaderLayoutCount());
        } else {
            throw new ArrayIndexOutOfBoundsException("inserted position most greater than 0 and less than data size");
        }
    }

    /**
     * add one new data
     */
    public void addData(T data) {
        mData.add(data);
        notifyItemInserted(mData.size() + getHeaderLayoutCount());
    }

    /**
     * add new data in to certain location
     *
     * @param position
     */
    public void addData(int position, List<T> data) {
        if (0 <= position && position < mData.size()) {
            mData.addAll(position, data);
            notifyItemRangeInserted(position + getHeaderLayoutCount(), data.size());
        } else {
            throw new ArrayIndexOutOfBoundsException("inserted position most greater than 0 and less than data size");
        }
    }

    /**
     * additional data;
     *
     * @param newData
     */
    public void addData(List<T> newData) {
        this.mData.addAll(newData);
        notifyItemRangeInserted(mData.size() - newData.size() + getHeaderLayoutCount(), newData.size());
    }

    /**
     * Get the data of list
     *
     * @return
     */
    public List<T> getData() {
        return mData;
    }

    /**
     * Get the data item associated with the specified position in the data set.
     *
     * @param position Position of the item whose data we want within the adapter's
     *                 data set.
     * @return The data at the specified position.
     */
    public T getItem(int position) {
        return mData.get(position);
    }

    /**
     * if setHeadView will be return 1 if not will be return 0.
     * notice: Deprecated! Use {@link ViewGroup#getChildCount()} of {@link #getHeaderLayout()} to replace.
     *
     * @return
     */
    @Deprecated
    public int getHeaderViewsCount() {
        return getHeaderLayoutCount();
    }

    /**
     * if mFooterLayout will be return 1 or not will be return 0.
     * notice: Deprecated! Use {@link ViewGroup#getChildCount()} of {@link #getFooterLayout()} to replace.
     *
     * @return
     */
    @Deprecated
    public int getFooterViewsCount() {
        return getFooterLayoutCount();
    }

    /**
     * if addHeaderView will be return 1, if not will be return 0
     */
    public int getHeaderLayoutCount() {
        if (mHeaderLayout == null || mHeaderLayout.getChildCount() == 0) {
            return 0;
        }
        return 1;
    }

    /**
     * if addFooterView will be return 1, if not will be return 0
     */
    public int getFooterLayoutCount() {
        if (mFooterLayout == null || mFooterLayout.getChildCount() == 0) {
            return 0;
        }
        return 1;
    }

    /**
     * if mEmptyView will be return 1 or not will be return 0
     *
     * @return
     */
    public int getEmptyViewCount() {
        if (mEmptyView == null || mEmptyView.getChildCount() == 0) {
            return 0;
        }
        if (!mIsUseEmpty) {
            return 0;
        }
        if (mData.size() != 0) {
            return 0;
        }
        return 1;
    }

    @Override
    public int getItemCount() {
        int count;
        if (getEmptyViewCount() == 1) {
            count = 1;
            if (mHeadAndEmptyEnable && getHeaderLayoutCount() != 0) {
                count++;
            }
            if (mFootAndEmptyEnable && getFooterLayoutCount() != 0) {
                count++;
            }
        } else {
            count = getHeaderLayoutCount() + mData.size() + getFooterLayoutCount() + getLoadMoreViewCount();
        }
        return count;
    }

    @Override
    public int getItemViewType(int position) {
        if (getEmptyViewCount() == 1) {
            boolean header = mHeadAndEmptyEnable && getHeaderLayoutCount() != 0;
            switch (position) {
                case 0:
                    if (header) {
                        return HEADER_VIEW;
                    } else {
                        return EMPTY_VIEW;
                    }
                case 1:
                    if (header) {
                        return EMPTY_VIEW;
                    } else {
                        return FOOTER_VIEW;
                    }
                case 2:
                    return FOOTER_VIEW;
                default:
                    return EMPTY_VIEW;
            }
        }
        autoLoadMore(position);
        int numHeaders = getHeaderLayoutCount();
        if (position < numHeaders) {
            return HEADER_VIEW;
        } else {
            int adjPosition = position - numHeaders;
            int adapterCount = mData.size();
            if (adjPosition < adapterCount) {
                return getDefItemViewType(adjPosition);
            } else {
                adjPosition = adjPosition - adapterCount;
                int numFooters = getFooterLayoutCount();
                if (adjPosition < numFooters) {
                    return FOOTER_VIEW;
                } else {
                    return LOADING_VIEW;
                }
            }
        }
    }

    protected int getDefItemViewType(int position) {
        return super.getItemViewType(position);
    }

    @Override
    public K onCreateViewHolder(ViewGroup parent, int viewType) {
        K baseViewHolder = null;
        this.mContext = parent.getContext();
        this.mLayoutInflater = LayoutInflater.from(mContext);
        switch (viewType) {
            case LOADING_VIEW:
                baseViewHolder = getLoadingView(parent);
                break;
            case HEADER_VIEW:
                baseViewHolder = createBaseViewHolder(mHeaderLayout);
                break;
            case EMPTY_VIEW:
                baseViewHolder = createBaseViewHolder(mEmptyView);
                break;
            case FOOTER_VIEW:
                baseViewHolder = createBaseViewHolder(mFooterLayout);
                break;
            default:
                baseViewHolder = onCreateDefViewHolder(parent, viewType);
        }
        return baseViewHolder;

    }

    private K getLoadingView(ViewGroup parent) {
        View view = getItemView(mLoadMoreView.getLayoutId(), parent);
        K holder = createBaseViewHolder(view);
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mLoadMoreView.getLoadMoreStatus() == LoadMoreView.STATUS_FAIL) {
                    mLoadMoreView.setLoadMoreStatus(LoadMoreView.STATUS_DEFAULT);
                    notifyItemChanged(getHeaderLayoutCount() + mData.size() + getFooterLayoutCount());
                }
            }
        });
        return holder;
    }

    /**
     * Called when a view created by this adapter has been attached to a window.
     * simple to solve item will layout using all
     * {@link #setFullSpan(RecyclerView.ViewHolder)}
     *
     * @param holder
     */
    @Override
    public void onViewAttachedToWindow(K holder) {
        super.onViewAttachedToWindow(holder);
        int type = holder.getItemViewType();
        if (type == EMPTY_VIEW || type == HEADER_VIEW || type == FOOTER_VIEW || type == LOADING_VIEW) {
            setFullSpan(holder);
        } else {
            addAnimation(holder);
        }
    }

    /**
     * When set to true, the item will layout using all span area. That means, if orientation
     * is vertical, the view will have full width; if orientation is horizontal, the view will
     * have full height.
     * if the hold view use StaggeredGridLayoutManager they should using all span area
     *
     * @param holder True if this item should traverse all spans.
     */
    protected void setFullSpan(RecyclerView.ViewHolder holder) {
        if (holder.itemView.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
            StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) holder.itemView.getLayoutParams();
            params.setFullSpan(true);
        }
    }

    @Override
    public void onAttachedToRecyclerView(final RecyclerView recyclerView) {
        super.onAttachedToRecyclerView(recyclerView);
        RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
        if (manager instanceof GridLayoutManager) {
            final GridLayoutManager gridManager = ((GridLayoutManager) manager);
            gridManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
                @Override
                public int getSpanSize(int position) {
                    int type = getItemViewType(position);
                    if (mSpanSizeLookup == null)
                        return (type == EMPTY_VIEW || type == HEADER_VIEW || type == FOOTER_VIEW || type == LOADING_VIEW) ? gridManager.getSpanCount() : 1;
                    else
                        return (type == EMPTY_VIEW || type == HEADER_VIEW || type == FOOTER_VIEW || type == LOADING_VIEW) ? gridManager.getSpanCount() : mSpanSizeLookup.getSpanSize(gridManager, position - getHeaderLayoutCount());
                }
            });
        }
    }

    private boolean flag = true;
    private SpanSizeLookup mSpanSizeLookup;

    public interface SpanSizeLookup {
        int getSpanSize(GridLayoutManager gridLayoutManager, int position);
    }

    /**
     * @param spanSizeLookup instance to be used to query number of spans occupied by each item
     */
    public void setSpanSizeLookup(SpanSizeLookup spanSizeLookup) {
        this.mSpanSizeLookup = spanSizeLookup;
    }

    /**
     * To bind different types of holder and solve different the bind events
     *
     * @param holder
     * @param positions
     * @see #getDefItemViewType(int)
     */
    @Override
    public void onBindViewHolder(K holder, int positions) {
        final int viewType = holder.getItemViewType();
        final int position = holder.getLayoutPosition() - getHeaderLayoutCount();

        switch (viewType) {
            case LOADING_VIEW:
                mLoadMoreView.convert(holder);
                break;
            case HEADER_VIEW:
                break;
            case EMPTY_VIEW:
                break;
            case FOOTER_VIEW:
                break;
            default:
                convert(holder, mData.get(position), position, isScrolling);
                break;
        }
    }

    protected K onCreateDefViewHolder(ViewGroup parent, int viewType) {
        return createBaseViewHolder(parent, mLayoutResId);
    }

    protected K createBaseViewHolder(ViewGroup parent, int layoutResId) {
        return createBaseViewHolder(getItemView(layoutResId, parent));
    }

    /**
     * if you want to use subclass of BaseViewHolder in the adapter,
     * you must override the method to create new ViewHolder.
     *
     * @param view view
     * @return new ViewHolder
     */
    protected K createBaseViewHolder(View view) {
        return (K) new BaseViewHolder(view);
    }

    /**
     * Return root layout of header
     */
    public LinearLayout getHeaderLayout() {
        return mHeaderLayout;
    }

    /**
     * Return root layout of footer
     */
    public LinearLayout getFooterLayout() {
        return mFooterLayout;
    }

    /**
     * Append header to the rear of the mHeaderLayout.
     *
     * @param header
     */
    public void addHeaderView(View header) {
        addHeaderView(header, -1);
    }

    /**
     * Add header view to mHeaderLayout and set header view position in mHeaderLayout.
     * When index = -1 or index >= child count in mHeaderLayout,
     * the effect of this method is the same as that of {@link #addHeaderView(View)}.
     *
     * @param header
     * @param index  the position in mHeaderLayout of this header.
     *               When index = -1 or index >= child count in mHeaderLayout,
     *               the effect of this method is the same as that of {@link #addHeaderView(View)}.
     */
    public void addHeaderView(View header, int index) {
        addHeaderView(header, index, LinearLayout.VERTICAL);
    }

    /**
     * @param header
     * @param index
     * @param orientation
     */
    public void addHeaderView(View header, int index, int orientation) {
        if (mHeaderLayout == null) {
            mHeaderLayout = new LinearLayout(header.getContext());
            if (orientation == LinearLayout.VERTICAL) {
                mHeaderLayout.setOrientation(LinearLayout.VERTICAL);
                mHeaderLayout.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
            } else {
                mHeaderLayout.setOrientation(LinearLayout.HORIZONTAL);
                mHeaderLayout.setLayoutParams(new LayoutParams(WRAP_CONTENT, MATCH_PARENT));
            }
        }
        index = index >= mHeaderLayout.getChildCount() ? -1 : index;
        mHeaderLayout.addView(header, index);
        if (mHeaderLayout.getChildCount() == 1) {
            int position = getHeaderViewPosition();
            if (position != -1) {
                notifyItemInserted(position);
            }
        }
    }

    /**
     * Append footer to the rear of the mFooterLayout.
     *
     * @param footer
     */
    public void addFooterView(View footer) {
        addFooterView(footer, -1);
    }

    /**
     * Add footer view to mFooterLayout and set footer view position in mFooterLayout.
     * When index = -1 or index >= child count in mFooterLayout,
     * the effect of this method is the same as that of {@link #addFooterView(View)}.
     *
     * @param footer
     * @param index  the position in mFooterLayout of this footer.
     *               When index = -1 or index >= child count in mFooterLayout,
     *               the effect of this method is the same as that of {@link #addFooterView(View)}.
     */
    public void addFooterView(View footer, int index) {
        if (mFooterLayout == null) {
            mFooterLayout = new LinearLayout(footer.getContext());
            mFooterLayout.setOrientation(LinearLayout.VERTICAL);
            mFooterLayout.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT));
        }
        index = index >= mFooterLayout.getChildCount() ? -1 : index;
        mFooterLayout.addView(footer, index);
        if (mFooterLayout.getChildCount() == 1) {
            int position = getFooterViewPosition();
            if (position != -1) {
                notifyItemInserted(position);
            }
        }
    }

    /**
     * remove header view from mHeaderLayout.
     * When the child count of mHeaderLayout is 0, mHeaderLayout will be set to null.
     *
     * @param header
     */
    public void removeHeaderView(View header) {
        if (getHeaderLayoutCount() == 0) return;

        mHeaderLayout.removeView(header);
        if (mHeaderLayout.getChildCount() == 0) {
            int position = getHeaderViewPosition();
            if (position != -1) {
                notifyItemRemoved(position);
            }
        }
    }

    /**
     * remove footer view from mFooterLayout,
     * When the child count of mFooterLayout is 0, mFooterLayout will be set to null.
     *
     * @param footer
     */
    public void removeFooterView(View footer) {
        if (getFooterLayoutCount() == 0) return;

        mFooterLayout.removeView(footer);
        if (mFooterLayout.getChildCount() == 0) {
            int position = getFooterViewPosition();
            if (position != -1) {
                notifyItemRemoved(position);
            }
        }
    }

    /**
     * remove all header view from mHeaderLayout and set null to mHeaderLayout
     */
    public void removeAllHeaderView() {
        if (getHeaderLayoutCount() == 0) return;

        mHeaderLayout.removeAllViews();
        int position = getHeaderViewPosition();
        if (position != -1) {
            notifyItemRemoved(position);
        }
    }

    /**
     * remove all footer view from mFooterLayout and set null to mFooterLayout
     */
    public void removeAllFooterView() {
        if (getFooterLayoutCount() == 0) return;

        mFooterLayout.removeAllViews();
        int position = getFooterViewPosition();
        if (position != -1) {
            notifyItemRemoved(position);
        }
    }

    private int getHeaderViewPosition() {
        //Return to header view notify position
        if (getEmptyViewCount() == 1) {
            if (mHeadAndEmptyEnable) {
                return 0;
            }
        } else {
            return 0;
        }
        return -1;
    }

    private int getFooterViewPosition() {
        //Return to footer view notify position
        if (getEmptyViewCount() == 1) {
            int position = 1;
            if (mHeadAndEmptyEnable && getHeaderLayoutCount() != 0) {
                position++;
            }
            if (mFootAndEmptyEnable) {
                return position;
            }
        } else {
            return getHeaderLayoutCount() + mData.size();
        }
        return -1;
    }

    public void setEmptyView(View emptyView) {
        boolean insert = false;
        if (mEmptyView == null) {
            mEmptyView = new FrameLayout(emptyView.getContext());
            mEmptyView.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT));
            insert = true;
        }
        mEmptyView.removeAllViews();
        mEmptyView.addView(emptyView);
        mIsUseEmpty = true;
        if (insert) {
            if (getEmptyViewCount() == 1) {
                int position = 0;
                if (mHeadAndEmptyEnable && getHeaderLayoutCount() != 0) {
                    position++;
                }
                notifyItemInserted(position);
            }
        }
    }

    /**
     * Call before {@link RecyclerView#setAdapter(RecyclerView.Adapter)}
     *
     * @param isHeadAndEmpty false will not show headView if the data is empty true will show emptyView and headView
     */
    public void setHeaderAndEmpty(boolean isHeadAndEmpty) {
        setHeaderFooterEmpty(isHeadAndEmpty, false);
    }

    /**
     * set emptyView show if adapter is empty and want to show headview and footview
     * Call before {@link RecyclerView#setAdapter(RecyclerView.Adapter)}
     *
     * @param isHeadAndEmpty
     * @param isFootAndEmpty
     */
    public void setHeaderFooterEmpty(boolean isHeadAndEmpty, boolean isFootAndEmpty) {
        mHeadAndEmptyEnable = isHeadAndEmpty;
        mFootAndEmptyEnable = isFootAndEmpty;
    }

    /**
     * Set whether to use empty view
     *
     * @param isUseEmpty
     */
    public void isUseEmpty(boolean isUseEmpty) {
        mIsUseEmpty = isUseEmpty;
    }

    /**
     * When the current adapter is empty, the BaseQuickAdapter can display a special view
     * called the empty view. The empty view is used to provide feedback to the user
     * that no data is available in this AdapterView.
     *
     * @return The view to show if the adapter is empty.
     */
    public View getEmptyView() {
        return mEmptyView;
    }

    private int mAutoLoadMoreSize = 1;

    public void setAutoLoadMoreSize(int autoLoadMoreSize) {
        if (autoLoadMoreSize > 1) {
            mAutoLoadMoreSize = autoLoadMoreSize;
        }
    }

    private void autoLoadMore(int position) {
        if (getLoadMoreViewCount() == 0) {
            return;
        }
        if (position < getItemCount() - mAutoLoadMoreSize) {
            return;
        }
        if (mLoadMoreView.getLoadMoreStatus() != LoadMoreView.STATUS_DEFAULT) {
            return;
        }
        mLoadMoreView.setLoadMoreStatus(LoadMoreView.STATUS_LOADING);
        if (!mLoading) {
            mLoading = true;
            mRequestLoadMoreListener.onLoadMoreRequested();
        }
    }

    /**
     * add animation when you want to show time
     *
     * @param holder
     */
    private void addAnimation(RecyclerView.ViewHolder holder) {
        if (mOpenAnimationEnable) {
            if (!mFirstOnlyEnable || holder.getLayoutPosition() > mLastPosition) {
                BaseAnimation animation = null;
                if (mCustomAnimation != null) {
                    animation = mCustomAnimation;
                } else {
                    animation = mSelectAnimation;
                }
                for (Animator anim : animation.getAnimators(holder.itemView)) {
                    startAnim(anim, holder.getLayoutPosition());
                }
                mLastPosition = holder.getLayoutPosition();
            }
        }
    }

    /**
     * set anim to start when loading
     *
     * @param anim
     * @param index
     */
    protected void startAnim(Animator anim, int index) {
        anim.setDuration(mDuration).start();
        anim.setInterpolator(mInterpolator);
    }

    /**
     * @param layoutResId ID for an XML layout resource to load
     * @param parent      Optional view to be the parent of the generated hierarchy or else simply an object that
     *                    provides a set of LayoutParams values for root of the returned
     *                    hierarchy
     * @return view will be return
     */
    protected View getItemView(int layoutResId, ViewGroup parent) {
        return mLayoutInflater.inflate(layoutResId, parent, false);
    }

    public interface RequestLoadMoreListener {

        void onLoadMoreRequested();

    }

    /**
     * Set the view animation type.
     *
     * @param animationType One of {@link #ALPHAIN}, {@link #SCALEIN}, {@link #SLIDEIN_BOTTOM}, {@link #SLIDEIN_LEFT}, {@link #SLIDEIN_RIGHT}.
     */
    public void openLoadAnimation(@AnimationType int animationType) {
        this.mOpenAnimationEnable = true;
        mCustomAnimation = null;
        switch (animationType) {
            case ALPHAIN:
                mSelectAnimation = new AlphaInAnimation();
                break;
            case SCALEIN:
                mSelectAnimation = new ScaleInAnimation();
                break;
            case SLIDEIN_BOTTOM:
                mSelectAnimation = new SlideInBottomAnimation();
                break;
            case SLIDEIN_LEFT:
                mSelectAnimation = new SlideInLeftAnimation();
                break;
            case SLIDEIN_RIGHT:
                mSelectAnimation = new SlideInRightAnimation();
                break;
            default:
                break;
        }
    }

    /**
     * Set Custom ObjectAnimator
     *
     * @param animation ObjectAnimator
     */
    public void openLoadAnimation(BaseAnimation animation) {
        this.mOpenAnimationEnable = true;
        this.mCustomAnimation = animation;
    }

    /**
     * To open the animation when loading
     */
    public void openLoadAnimation() {
        this.mOpenAnimationEnable = true;
    }

    /**
     * To close the animation when loading
     */
    public void closeLoadAnimation() {
        this.mOpenAnimationEnable = false;
        this.mSelectAnimation = null;
        this.mCustomAnimation = null;
        this.mDuration = 0;
    }

    /**
     * {@link #addAnimation(RecyclerView.ViewHolder)}
     *
     * @param firstOnly true just show anim when first loading false show anim when load the data every time
     */
    public void isFirstOnly(boolean firstOnly) {
        this.mFirstOnlyEnable = firstOnly;
    }

    /**
     * Implement this method and use the helper to adapt the view to the given item.
     *
     * @param helper      A fully initialized helper.
     * @param item        the item that needs to be displayed.
     * @param position    the item position
     * @param isScrolling RecyclerView is scrolling
     */
    protected abstract void convert(K helper, T item, int position, boolean isScrolling);

    /**
     * Get the row id associated with the specified position in the list.
     *
     * @param position The position of the item within the adapter's data set whose row id we want.
     * @return The id of the item at the specified position.
     */
    @Override
    public long getItemId(int position) {
        return position;
    }

    private int recursiveExpand(int position, @NonNull List list) {
        int count = 0;
        int pos = position + list.size() - 1;
        for (int i = list.size() - 1; i >= 0; i--, pos--) {
            if (list.get(i) instanceof IExpandable) {
                IExpandable item = (IExpandable) list.get(i);
                if (item.isExpanded() && hasSubItems(item)) {
                    List subList = item.getSubItems();
                    mData.addAll(pos + 1, subList);
                    int subItemCount = recursiveExpand(pos + 1, subList);
                    count += subItemCount;
                }
            }
        }
        return count;

    }

    /**
     * Expand an expandable item
     *
     * @param position     position of the item
     * @param animate      expand items with animation
     * @param shouldNotify notify the RecyclerView to rebind items, <strong>false</strong> if you want to do it yourself.
     * @return the number of items that have been added.
     */
    public int expand(@IntRange(from = 0) int position, boolean animate, boolean shouldNotify) {
        position -= getHeaderLayoutCount();

        IExpandable expandable = getExpandableItem(position);
        if (expandable == null) {
            return 0;
        }
        if (!hasSubItems(expandable)) {
            expandable.setExpanded(false);
            return 0;
        }
        int subItemCount = 0;
        if (!expandable.isExpanded()) {
            List list = expandable.getSubItems();
            mData.addAll(position + 1, list);
            subItemCount += recursiveExpand(position + 1, list);

            expandable.setExpanded(true);
            subItemCount += list.size();
        }
        int parentPos = position + getHeaderLayoutCount();
        if (shouldNotify) {
            if (animate) {
                notifyItemChanged(parentPos);
                notifyItemRangeInserted(parentPos + 1, subItemCount);
            } else {
                notifyDataSetChanged();
            }
        }
        return subItemCount;
    }

    /**
     * Expand an expandable item
     *
     * @param position position of the item, which includes the header layout count.
     * @param animate  expand items with animation
     * @return the number of items that have been added.
     */
    public int expand(@IntRange(from = 0) int position, boolean animate) {
        return expand(position, animate, true);
    }

    /**
     * Expand an expandable item with animation.
     *
     * @param position position of the item, which includes the header layout count.
     * @return the number of items that have been added.
     */
    public int expand(@IntRange(from = 0) int position) {
        return expand(position, true, true);
    }

    public int expandAll(int position, boolean animate, boolean notify) {
        position -= getHeaderLayoutCount();

        T endItem = null;
        if (position + 1 < this.mData.size()) {
            endItem = getItem(position + 1);
        }

        IExpandable expandable = getExpandableItem(position);
        if (!hasSubItems(expandable)) {
            return 0;
        }

        int count = expand(position + getHeaderLayoutCount(), false, false);
        for (int i = position + 1; i < this.mData.size(); i++) {
            T item = getItem(i);

            if (item == endItem) {
                break;
            }
            if (isExpandable(item)) {
                count += expand(i + getHeaderLayoutCount(), false, false);
            }
        }

        if (notify) {
            if (animate) {
                notifyItemRangeInserted(position + getHeaderLayoutCount() + 1, count);
            } else {
                notifyDataSetChanged();
            }
        }
        return count;
    }

    /**
     * expand the item and all its subItems
     *
     * @param position position of the item, which includes the header layout count.
     * @param init     whether you are initializing the recyclerView or not.
     *                 if <strong>true</strong>, it won't notify recyclerView to redraw UI.
     * @return the number of items that have been added to the adapter.
     */
    public int expandAll(int position, boolean init) {
        return expandAll(position, true, !init);
    }

    private int recursiveCollapse(@IntRange(from = 0) int position) {
        T item = getItem(position);
        if (!isExpandable(item)) {
            return 0;
        }
        IExpandable expandable = (IExpandable) item;
        int subItemCount = 0;
        if (expandable.isExpanded()) {
            List<T> subItems = expandable.getSubItems();
            for (int i = subItems.size() - 1; i >= 0; i--) {
                T subItem = subItems.get(i);
                int pos = getItemPosition(subItem);
                if (pos < 0) {
                    continue;
                }
                if (subItem instanceof IExpandable) {
                    subItemCount += recursiveCollapse(pos);
                }
                mData.remove(pos);
                subItemCount++;
            }
        }
        return subItemCount;
    }

    /**
     * Collapse an expandable item that has been expanded..
     *
     * @param position the position of the item, which includes the header layout count.
     * @param animate  collapse with animation or not.
     * @param notify   notify the recyclerView refresh UI or not.
     * @return the number of subItems collapsed.
     */
    public int collapse(@IntRange(from = 0) int position, boolean animate, boolean notify) {
        position -= getHeaderLayoutCount();

        IExpandable expandable = getExpandableItem(position);
        if (expandable == null) {
            return 0;
        }
        int subItemCount = recursiveCollapse(position);
        expandable.setExpanded(false);
        int parentPos = position + getHeaderLayoutCount();
        if (notify) {
            if (animate) {
                notifyItemChanged(parentPos);
                notifyItemRangeRemoved(parentPos + 1, subItemCount);
            } else {
                notifyDataSetChanged();
            }
        }
        return subItemCount;
    }

    /**
     * Collapse an expandable item that has been expanded..
     *
     * @param position the position of the item, which includes the header layout count.
     * @return the number of subItems collapsed.
     */
    public int collapse(@IntRange(from = 0) int position) {
        return collapse(position, true, true);
    }

    /**
     * Collapse an expandable item that has been expanded..
     *
     * @param position the position of the item, which includes the header layout count.
     * @return the number of subItems collapsed.
     */
    public int collapse(@IntRange(from = 0) int position, boolean animate) {
        return collapse(position, animate, true);
    }

    private int getItemPosition(T item) {
        return item != null && mData != null && !mData.isEmpty() ? mData.indexOf(item) : -1;
    }

    private boolean hasSubItems(IExpandable item) {
        List list = item.getSubItems();
        return list != null && list.size() > 0;
    }

    private boolean isExpandable(T item) {
        return item != null && item instanceof IExpandable;
    }

    private IExpandable getExpandableItem(int position) {
        T item = getItem(position);
        if (isExpandable(item)) {
            return (IExpandable) item;
        } else {
            return null;
        }
    }

    /**
     * Get the parent item position of the IExpandable item
     *
     * @return return the closest parent item position of the IExpandable.
     * if the IExpandable item's level is 0, return itself position.
     * if the item's level is negative which mean do not implement this, return a negative
     * if the item is not exist in the data list, return a negative.
     */
    public int getParentPosition(@NonNull T item) {
        int position = getItemPosition(item);
        if (position == -1) {
            return -1;
        }

        // if the item is IExpandable, return a closest IExpandable item position whose level smaller than this.
        // if it is not, return the closest IExpandable item position whose level is not negative
        int level;
        if (item instanceof IExpandable) {
            level = ((IExpandable) item).getLevel();
        } else {
            level = Integer.MAX_VALUE;
        }
        if (level == 0) {
            return position;
        } else if (level == -1) {
            return -1;
        }

        for (int i = position; i >= 0; i--) {
            T temp = mData.get(i);
            if (temp instanceof IExpandable) {
                IExpandable expandable = (IExpandable) temp;
                if (expandable.getLevel() >= 0 && expandable.getLevel() < level) {
                    return i;
                }
            }
        }
        return -1;
    }

    public boolean isFirstDataItem(int dataItemPosition) {
        return dataItemPosition == 0;
    }

    public boolean isLastDataItem(int dataItemPosition) {
        return dataItemPosition == mData.size() - 1;
    }

    public int getViewHolderPosition(int dataItemPosition) {
        return getHeaderLayoutCount() + dataItemPosition;
    }

    public int getBottomDataPosition() {
        return getHeaderLayoutCount() + mData.size() - 1;
    }
}


text:
 Input JSON File Directory

 Author : Tilman Schulz

Date: 2015-12-29

 General Idea

All data which is abstractable should resite in this directory, and should be read by cfengine at runtime of the agent via "readjson/readdata".

 Other conventions I find usefull

 File naming convention : Files will take names which correspond to $(this.bundle).json in cfengine!  Caution: not completely true by now

 File structure requirements :

redpajama_set_name: RedPajamaGithub


text:
namespace reprize
{
namespace res
{
class Entry
{
public:
    virtual ~Entry(void) {}
    virtual class Node* Find(const Str& node_name_) { return NULL; }
    virtual Node* Find(const NID nid_) { return NULL; }
    virtual Node* Current(void) { return NULL; }
    virtual void First(void) {}
    virtual void Next(void) {}
    virtual const bool IsDone(void) const { return true; }
    virtual const bool IsEmpty(void) const  { return true; }
    virtual Size32 Amount(void)  { return 0; }
    virtual const bool Move(class DirEntry& de_) { return false; }
    virtual const bool Remove(void) { return false; }
    virtual const bool Graft(Node* parent_, Node* node_) { return false; }
    virtual void CloneChild(Node* parent_) {}
    virtual void Clear(void) {}

    virtual Node* Parent(void) { return NULL; }

protected:
    Entry(void) {}
};
}
}

#endif


text:
% Created 2017-10-23 Mon 00:20
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
\usepackage{amssymb}
\usepackage{hyperref}
\tolerance=1000
\author{Christopher Cundy}
\date{\today}
\title{to\_do}
\hypersetup{
  pdfkeywords={},
  pdfsubject={},
  pdfcreator={Emacs 25.1.1 (Org mode 8.2.10)}}
\begin{document}

\maketitle
\tableofcontents

\section{To do for paper}
\label{sec-1}
\subsection{Edit all}
\label{sec-1-1}
\subsection{Look up templates etc, double-check there's not one out there}
\label{sec-1-2}
\subsection{Do and write up the experiments}
\label{sec-1-3}
\subsubsection{Synthetic Task}
\label{sec-1-3-1}
\begin{enumerate}
\item Already done, written up. Need to review
\label{sec-1-3-1-1}
\end{enumerate}
\subsubsection{Medical Task}
\label{sec-1-3-2}
\begin{enumerate}
\item Being done, need to check on testing set
\label{sec-1-3-2-1}
\item Need to write up
\label{sec-1-3-2-2}
\end{enumerate}
\subsubsection{Throughput Task}
\label{sec-1-3-3}
\begin{enumerate}
\item Chat to Eric about this
\label{sec-1-3-3-1}
\item Just generate random data
\label{sec-1-3-3-2}
\end{enumerate}
\subsubsection{PLR/SLR comparison}
\label{sec-1-3-4}
\begin{enumerate}
\item Have the pure kernel data
\label{sec-1-3-4-1}

\item Do that for random data
\label{sec-1-3-4-2}
\item Do a 2-layer network, with varying seq$_{\text{len}}$
\label{sec-1-3-4-3}
\item Report the throughput
\label{sec-1-3-4-4}

\begin{center}
\begin{tabular}{lrrrr}
Sequence Length & LS-LSTM & SRU & QRNN(2) & QRNN(10\\
\hline
16 & 0.61 & 0.28 & 0.38 & 0.78\\
256 & 0.91 & 0.84 & 0.86 & 0.99\\
4,096 & 0.98 & 1.38 & 1.18 & 1.05\\
65,536 & 1.41 & 9.21 & 6.68 & 2.05\\
\end{tabular}
\end{center}
For an input$_{\text{size}}$ of 24, output 2, hidden$_{\text{size}}$ 256,
batch$_{\text{size}}$ 65536 / seq$_{\text{len}}$
\end{enumerate}

\subsection{Collate the experiments and smooth}
\label{sec-1-4}
\subsection{Think about the overall message of the piece and rewrite as necessary}
\label{sec-1-5}
\subsection{Send to Adam, Andy to check}
\label{sec-1-6}
\subsection{Submit}
\label{sec-1-7}
\subsubsection{Then go to party and relax the fuck out}
\label{sec-1-7-1}

\section{Timeline}
\label{sec-2}
\subsection{Saturday evening:}
\label{sec-2-1}
\subsubsection{Done interesting medical results, tested on testing set}
\label{sec-2-1-1}
\subsubsection{Looked at throughput task}
\label{sec-2-1-2}
\subsubsection{Done PLR / SLR throughput task}
\label{sec-2-1-3}
\subsection{Sunday evening:}
\label{sec-2-2}
\subsubsection{Fully written up medical task}
\label{sec-2-2-1}
\subsubsection{Written up throuput and PLR/SLR task}
\label{sec-2-2-2}
\subsubsection{Start editing the paper, smoothing into a cohesive whole}
\label{sec-2-2-3}
\subsection{Monday evening:}
\label{sec-2-3}
\subsubsection{Finish editing, send off to everyone else}
\label{sec-2-3-1}

\section{Paper structure}
\label{sec-3}
\subsection{Introduction, abstract, background}
\label{sec-3-1}
\subsubsection{Describe}
\label{sec-3-1-1}
We can apply the PLR method to any architecture that satisfies the
constraints. E.g. SRU, QRNN, etc. Introduce LS-LSTM as good substitute.
Describe how previous papers have shown that linear LSTMs work well, this
approach allows us to speed it up.
\subsection{Experiments}
\label{sec-3-2}
\subsubsection{Benchmarks}
\label{sec-3-2-1}
\begin{enumerate}
\item Throughput of pure PLR kernel vs SLR kernel
\label{sec-3-2-1-1}
\item Show how it speeds up the SRU, QRNN, and LS-LSTM
\label{sec-3-2-1-2}
\item Show how the LS-LSTM has much better throughput than the CudnnLSTM
\label{sec-3-2-1-3}
\end{enumerate}
\subsubsection{Synthetic task to show that linear LSTMs can still work well}
\label{sec-3-2-2}
\subsubsection{Medical task}
\label{sec-3-2-3}

31.4 * (4.3 * 6) =
\textasciitilde{}50 * \textasciitilde{}74
135 * 190
% Emacs 25.1.1 (Org mode 8.2.10)
\end{document}


text:
@interface ErrorMessageXMLModel : NSObject
@property (nonatomic, assign) long errorCode;// 错误码
@property (nonatomic, copy) NSString *errorMessage;// 错误信息

- (instancetype) initWithXML:(ONOXMLElement *)xml;
@end


text:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Xml.Linq;

namespace ApiPortVS
{
    /// <summary>
    /// Because the VSIX runs inside devenv.exe, the only configuration file that is used for redirects is
    /// devenv.exe.config.We don't want to modify this machine wide configuration so we are manually setting
    /// the redirects.
    /// More info: http://stackoverflow.com/a/31248093/4220757
    /// </summary>
    internal class AssemblyRedirectResolver
    {
        private readonly IDictionary<string, AssemblyRedirect> _redirectsDictionary;

        public AssemblyRedirectResolver(string configFile)
        {
            var xml = XDocument.Load(configFile);
            Func<string, XName> getFullName = (name) => { return XName.Get(name, "urn:schemas-microsoft-com:asm.v1"); };

            var redirects = from element in xml.Descendants(getFullName("dependentAssembly"))
                            let identity = element.Element(getFullName("assemblyIdentity"))
                            let redirect = element.Element(getFullName("bindingRedirect"))
                            let name = identity.Attribute("name").Value
                            let publicKey = identity.Attribute("publicKeyToken").Value
                            let newVersion = redirect.Attribute("newVersion").Value
                            select new AssemblyRedirect(name, newVersion, publicKey);

            _redirectsDictionary = redirects.ToDictionary(x => x.Name);
        }

        public AssemblyRedirectResolver(DirectoryInfo assemblyFolder)
        {
            var redirects = assemblyFolder.GetFiles("*.dll")
                .Select(dll => {
                    var name = AssemblyName.GetAssemblyName(dll.FullName);
                    var publicKeyToken = name.GetPublicKeyToken().Aggregate("", (s, b) => s += b.ToString("x2", CultureInfo.InvariantCulture));
                    return new AssemblyRedirect(name.Name, name.Version.ToString(), publicKeyToken);
                });

            _redirectsDictionary = redirects.ToDictionary(x => x.Name);
        }

        public Assembly ResolveAssembly(string assemblyName, Assembly requestingAssembly)
        {
            // Use latest strong name & version when trying to load SDK assemblies
            var requestedAssembly = new AssemblyName(assemblyName);

            AssemblyRedirect redirectInformation;

            if (!_redirectsDictionary.TryGetValue(requestedAssembly.Name, out redirectInformation))
            {
                return null;
            }

            Trace.WriteLine("Redirecting assembly load of " + assemblyName
                          + ",\tloaded by " + (requestingAssembly == null ? "(unknown)" : requestingAssembly.FullName));

            var alreadyLoadedAssembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a =>
            {
                var assm = a.GetName();
                return string.Equals(assm.Name, requestedAssembly.Name, StringComparison.Ordinal)
                    && redirectInformation.TargetVersion.Equals(assm.Version);
            });

            if (alreadyLoadedAssembly != default(Assembly))
            {
                return alreadyLoadedAssembly;
            }

            requestedAssembly.Version = redirectInformation.TargetVersion;
            requestedAssembly.SetPublicKeyToken(new AssemblyName("x, PublicKeyToken=" + redirectInformation.PublicKeyToken).GetPublicKeyToken());
            requestedAssembly.CultureInfo = CultureInfo.InvariantCulture;

            return Assembly.Load(requestedAssembly);
        }
    }

    internal class AssemblyRedirect
    {
        public readonly string Name;

        public readonly string PublicKeyToken;

        public readonly Version TargetVersion;

        public AssemblyRedirect(string name, string version, string publicKeyToken)
        {
            Name = name;
            TargetVersion = new Version(version);
            PublicKeyToken = publicKeyToken;
        }
    }
}


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
Bot. Tidsskr. 18: 65-78 (1892)

#### Original name
Scutularia multiguttulata Rostr.

### Remarks
null


text:
package internalversion

import (
	user "github.com/openshift/origin/pkg/user/apis/user"
	"k8s.io/apimachinery/pkg/api/errors"
	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/labels"
	"k8s.io/client-go/tools/cache"
)

// GroupLister helps list Groups.
type GroupLister interface {
	// List lists all Groups in the indexer.
	List(selector labels.Selector) (ret []*user.Group, err error)
	// Get retrieves the Group from the index for a given name.
	Get(name string) (*user.Group, error)
	GroupListerExpansion
}

// groupLister implements the GroupLister interface.
type groupLister struct {
	indexer cache.Indexer
}

// NewGroupLister returns a new GroupLister.
func NewGroupLister(indexer cache.Indexer) GroupLister {
	return &groupLister{indexer: indexer}
}

// List lists all Groups in the indexer.
func (s *groupLister) List(selector labels.Selector) (ret []*user.Group, err error) {
	err = cache.ListAll(s.indexer, selector, func(m interface{}) {
		ret = append(ret, m.(*user.Group))
	})
	return ret, err
}

// Get retrieves the Group from the index for a given name.
func (s *groupLister) Get(name string) (*user.Group, error) {
	key := &user.Group{ObjectMeta: v1.ObjectMeta{Name: name}}
	obj, exists, err := s.indexer.Get(key)
	if err != nil {
		return nil, err
	}
	if !exists {
		return nil, errors.NewNotFound(user.Resource("group"), name)
	}
	return obj.(*user.Group), nil
}


text:
package May2021GoogLeetcode;

public class _0353DesignSnakeGame {

	public static void main(String[] args) {
		SnakeGame snakeGame = new SnakeGame(3, 2, new int[][] { new int[] { 1, 2 }, new int[] { 0, 1 } });

		System.out.println(snakeGame.move("R"));
		System.out.println(snakeGame.move("D"));
		System.out.println(snakeGame.move("R"));
		System.out.println(snakeGame.move("U"));
		System.out.println(snakeGame.move("L"));
		System.out.println(snakeGame.move("U"));

		snakeGame = new SnakeGame(2, 2, new int[][] { new int[] { 0, 1 } });
		System.out.println(snakeGame.move("R"));
		System.out.println(snakeGame.move("D"));

		snakeGame = new SnakeGame(3, 3, new int[][] { new int[] { 2, 0 }, new int[] { 0, 0 }, new int[] { 0, 2 },
				new int[] { 0, 1 }, new int[] { 2, 2 }, new int[] { 0, 1 } });
		System.out.println(snakeGame.move("D"));
		System.out.println(snakeGame.move("D"));
		System.out.println(snakeGame.move("R"));
		System.out.println(snakeGame.move("U"));
		System.out.println(snakeGame.move("U"));
		System.out.println(snakeGame.move("L"));
		System.out.println(snakeGame.move("D"));
		System.out.println(snakeGame.move("R"));
		System.out.println(snakeGame.move("R"));
		System.out.println(snakeGame.move("U"));
		System.out.println(snakeGame.move("L"));
		System.out.println(snakeGame.move("L"));
		System.out.println(snakeGame.move("D"));
		System.out.println(snakeGame.move("R"));
		System.out.println(snakeGame.move("U"));

		snakeGame = new SnakeGame(3, 3,
				new int[][] { new int[] { 2, 0 }, new int[] { 0, 0 }, new int[] { 0, 2 }, new int[] { 2, 2 } });
		System.out.println(snakeGame.move("D"));
		System.out.println(snakeGame.move("D"));
		System.out.println(snakeGame.move("R"));
		System.out.println(snakeGame.move("U"));
		System.out.println(snakeGame.move("U"));
		System.out.println(snakeGame.move("L"));
		System.out.println(snakeGame.move("D"));
		System.out.println(snakeGame.move("R"));
		System.out.println(snakeGame.move("R"));
		System.out.println(snakeGame.move("U"));
		System.out.println(snakeGame.move("L"));
		System.out.println(snakeGame.move("D"));
	}

	static class Pair {
		int x, y;

		public Pair(int x, int y) {
			this.x = x;
			this.y = y;
		}
	}

	static class SnakeGame {

		/**
		 * Initialize your data structure here.
		 *
		 * @param width  - screen width
		 * @param height - screen height
		 * @param food   - A list of food positions E.g food = [[1,1], [1,0]] means the
		 *               first food is positioned at [1,1], the second is at [1,0].
		 */
		public SnakeGame(int width, int height, int[][] food) {
		}

		/**
		 * Moves the snake.
		 *
		 * @param direction - 'U' = Up, 'L' = Left, 'R' = Right, 'D' = Down
		 * @return The game's score after the move. Return -1 if game over. Game over
		 *         when snake crosses the screen boundary or bites its body.
		 */
		public int move(String direction) {

		}

	}

}


text:
Unreleased Changes
------------------

1.20.0 (2022-11-16)
------------------

* Feature - Add support for PagerDuty integrations on ResponsePlan, IncidentRecord, and RelatedItem APIs

1.19.0 (2022-11-11)
------------------

* Feature - RelatedItems now have an ID field which can be used for referencing them else where. Introducing event references in TimelineEvent API and increasing maximum length of "eventData" to 12K characters.

1.18.0 (2022-11-02)
------------------

* Feature - Adds support for tagging replication-set on creation.

1.17.0 (2022-10-25)
------------------

* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.

1.16.0 (2022-10-13)
------------------

* Feature - Update RelatedItem enum to support Tasks

1.15.0 (2022-07-05)
------------------

* Feature - Adds support for tagging incident-record on creation by providing incident tags in the template within a response-plan.

1.14.0 (2022-05-12)
------------------

* Feature - Adding support for dynamic SSM Runbook parameter values. Updating validation pattern for engagements. Adding ConflictException to UpdateReplicationSet API contract.

1.13.0 (2022-03-16)
------------------

* Feature - Removed incorrect validation pattern for IncidentRecordSource.invokedBy

1.12.0 (2022-02-24)
------------------

* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.

1.11.0 (2022-02-07)
------------------

* Feature - Update RelatedItem enum to support SSM Automation

1.10.0 (2022-02-03)
------------------

* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.

1.9.0 (2021-12-21)
------------------

* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.

1.8.0 (2021-11-30)
------------------

* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.

1.7.0 (2021-11-04)
------------------

* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.

1.6.0 (2021-10-28)
------------------

* Feature - Updating documentation, adding new field to ConflictException to indicate earliest retry timestamp for some operations, increase maximum length of nextToken fields

1.5.0 (2021-10-18)
------------------

* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.

1.4.0 (2021-09-01)
------------------

* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.

1.3.0 (2021-08-04)
------------------

* Feature - Documentation updates for Incident Manager.

1.2.0 (2021-07-30)
------------------

* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.

1.1.0 (2021-07-28)
------------------

* Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.

1.0.0 (2021-05-11)
------------------

* Feature - Initial release of `aws-sdk-ssmincidents`.


text:
require 'singleton'
module CBR
  class Engine
    include Singleton
    attr_accessor :dedicated_cases, :treshold, :config

    def initialize
      @config ||= CBR::Config.instance
      @treshold = BigDecimal.new('0.0')
    end

    def retrieve(c, treshold=nil)
      result = []
      attributes = c.cbr_attributes
      if attributes
        target_case = c.cbr_target_case
        @config ||= CBR::Config.instance
        cbr_config = target_case.cbr_config
        @config.similarities = cbr_config if cbr_config
        @config.calculate_relative_weights!
        treshold ||= @treshold
        treshold = BigDecimal.new(treshold)
        cases.each do |c|
          c.compared_case = target_case
          c.score_details = {}
          attributes.each do |attr_name, attr_value|
            c.score_details[attr_name] = @config.weighted_similarity(c, attr_name, attr_value)
          end
          c.score = c.score_details.values.map {|ws| ws[:value]}.reduce(:+)
          #pp c.score
          result << c if c.score >= treshold
        end
      end
      result
    end

    def retrieve_all(c)
      all_treshold = BigDecimal.new('0.0')
      retrieve(c, all_treshold)
    end

    def calculate_score(c)
      attributes = c.cbr_attributes
      if attributes
        target_case = c.cbr_target_case
        @config ||= CBR::Config.instance
        cbr_config = target_case.cbr_config
        @config.similarities = cbr_config if cbr_config
        @config.calculate_relative_weights!
        c.compared_case = target_case
        c.score_details = {}
        attributes.select {|a_name, a_val| @config.similarities.keys.include?(a_name)}.each do |attr_name, attr_value|
          c.score_details[attr_name] = @config.weighted_similarity(c, attr_name, attr_value)
        end
        c.score_details['penalty'] = {value: c.cbr_penalty}
        c.score = [BigDecimal.new(1), [BigDecimal.new(0), (c.score_details.values.map {|ws| ws[:value]}.reduce(:+))].max].min
        c.score
      end
      c
    end

    def cases
      if dedicated_cases
        dedicated_cases
      else
        ObjectSpace.each_object(Class).select {|c| c.included_modules.include? CBR::Case}.map(&:all).reduce(:+)
      end
    end

  end
end


text:
//
//  Utility+Encrypt.m
//  TCTravel_IPhone
//
//  Created by Tracy-jun on 14/11/13.
//
//

#import "Utility+Encrypt.h"
//#import "TCDateFormatter.h"

@implementation Utility (Encrypt)

/*---------------------个人信息加密---------------------*/
//手机电话加密
+(NSString *)encryptPhoneNum:(NSString *)_phoneNum{
    if ([_phoneNum length]>3) {
        NSString *firstNum  = [_phoneNum substringToIndex:3];
        NSString *secondNum = @"";
        if ([_phoneNum length]>7) {
            secondNum = [_phoneNum substringFromIndex:7];
        }
        return [NSString stringWithFormat:@"%@****%@",firstNum,secondNum];
    }else{
        return @"";
    }
}
//判断座机
+ (BOOL)isMobileNumber:(NSString *)mobileNum
{
    //判断电话区号后面没有-号表达式
    NSString *MOBILE = @"^1(3[0-9]|5[0-9]|8[0-9])\\d{8}$";
    //判断电话区号后面有-号表达式
    NSString *USUALMOBILE = @"(\\d{2,5}-\\d{7,8}(-\\d{1,})?)|(13\\d{9})|(159\\d{8})";
    //判断是否是有效电话号码表达式
    NSString *PHS = @"^0(10|2[0-5789]|\\d{3})\\d{7,8}$";

    NSPredicate *regextestmobile = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", MOBILE];
    NSPredicate *Usualregextestmobile = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", USUALMOBILE];
    NSPredicate *regextesPhs = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", PHS];

    if (([regextestmobile evaluateWithObject:mobileNum] == YES)
        ||([regextesPhs evaluateWithObject:mobileNum] == YES)||([Usualregextestmobile evaluateWithObject:mobileNum] == YES))
    {
        //有效电话或者手机号
        return YES;
    }
    else
    {
        UIAlertView *alertview = [[UIAlertView alloc] initWithTitle:@"提示" message:@"您输入的电话或者手机号码无效,请检查是否输入有误!!" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
        [alertview show];
        return NO;
    }
}

//证件号加密
+(NSString *)encryptCertNo:(NSString *)_certNo{
    if ([_certNo length]>2) {
        NSString *firstMes   = [_certNo substringToIndex:1];
        NSInteger iNum       = [_certNo length];
        NSString *thirdMes   = [_certNo substringFromIndex:iNum-1];
        NSString *secondeMes = @"";
        for (int i=0; i<iNum-2; i++) {
            secondeMes = [NSString stringWithFormat:@"%@*",secondeMes];
        }
        return [NSString stringWithFormat:@"%@%@%@",firstMes,secondeMes,thirdMes];
    }else{
        return _certNo;
    }
}

//邮箱加密
+(NSString *)encryptEmail:(NSString *)_email{
    NSRange range         = [_email rangeOfString:@"@"];
    NSString *strbehindAt = [_email substringFromIndex:range.location];//@后部分
    NSString *strBeforeAt = [_email substringToIndex:range.location-1];//@前部分
    if ([strBeforeAt length]>2) {
        NSString *firstMes = [strBeforeAt substringToIndex:1];
        NSInteger iNum = [strBeforeAt length];
        NSString *thirdMes = [strBeforeAt substringFromIndex:iNum-1];
        NSString *secondMes = @"";
        for (int i=0; i<iNum-2; i++) {
            secondMes = [NSString stringWithFormat:@"%@*",secondMes];
        }
        return [NSString stringWithFormat:@"%@%@%@%@",firstMes,secondMes,thirdMes,strbehindAt];
    }else{
        return _email;
    }
}

//验证用户名
+ (BOOL)checkPersonName:(NSString *)str{
    //    NSString * regex = @"^(?:[\\u4e00-\\u9fa5]*[a-zA-Z]*\\•?\\·?)+$";
    NSString * regex = @"^(?:[\\u4e00-\\u9fa5]*[a-zA-Z]*)+$";
    NSPredicate *prd = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
    return [prd evaluateWithObject:str];
}

//验证用户名是否有重复字符 规则:包含四个及四个以上连续出现的字符,返回YES,否则返回NO
+ (BOOL)checkPersonNameRepetition:(NSString *)str
{
    NSString * regex = @"^.*(.)\\1{3}.*$";
    NSPredicate *prd = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
    return [prd evaluateWithObject:str];
}

+ (BOOL)checkIDCard:(NSString *)str{
    //max 2013年以后,15位身份证失效
    if (str==nil||str.length<=0) {
        return NO;
    }
    return checkIDfromchar((char *)[[str uppercaseString] UTF8String]);
}

+(BOOL)checkInterContactNameRule:(NSString *)name
{
    NSString * regex        = @"(^[A-Za-z]*$)";
    NSPredicate * pred      = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
    return [pred evaluateWithObject:name];
}

//验证用户填写订单时的姓名
+(NSString *)checkUserName:(NSString *)str
{
    NSString *_strErr=@"";

    // 全字母 ok
    NSString *regexnext = @"^[A-Za-z]+$";
    NSPredicate *predicatenext = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regexnext];
    if ([predicatenext evaluateWithObject:str]) {
        return _strErr;
    }

    if ([str isEqualToString:@"先生"]||[str isEqualToString:@"小姐"]||[str isEqualToString:@"女士"]) {
        _strErr=@"姓名中不能含有"先生"、"女士"或"小姐"字词";
    }

    if (str.length<=1) {
        _strErr=@"姓名过短,请输入正确姓名";
    }

    //不能含有数字或标点符号  @"^[\u4e00-\u9fa5]+$"
    NSString *regex= @"^[a-zA-Z_\u4e00-\u9fa5]+$";
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
    if (![predicate evaluateWithObject:str]) {
        _strErr=@"姓名中不能含有除汉字、字母以外的其它字符";
    }

    return _strErr;
}

+(BOOL)checkNineNumofAtoZandatozRule:(NSString *)name
{
    NSString * regex = @"^[A-Za-z]{8,20}$";
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
    BOOL isMatch = [pred evaluateWithObject:name];
    return isMatch;
}

+(BOOL)isPhoneNumber:(NSString *)phoneNumber
{
    if ([phoneNumber length]==0||phoneNumber==nil||phoneNumber.length<11) {
        return NO;
    }
    NSString *Regex = @"^(13[0-9]|15[0-9]|18[0-9]|17[0-9]|147)\\d{8}$";
    NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", Regex];
    return [emailTest evaluateWithObject:phoneNumber];
}

+ (BOOL)isZipCodeNumber:(NSString *)zipCodeNumber{
    if (zipCodeNumber == nil || [zipCodeNumber isEqualToString:@""]) {
        return NO;
    }
    NSString *Regex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
    NSPredicate *zipTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", Regex];
    return[zipTest evaluateWithObject:zipCodeNumber];
}

+(BOOL)checkStringChineseEnglish:(NSString *)_str{
    BOOL bNotChinese=NO;
    for (int i =0; i<_str.length; i++) {
        if ([[_str substringWithRange:NSMakeRange(i,1)] dataUsingEncoding:NSASCIIStringEncoding])
        {
            bNotChinese=YES;
        }
        else if (bNotChinese)
        {
            return NO;
        }
    }
    return YES;
}

+(BOOL)checkStringIsChinese:(NSString *)_string
{
    BOOL bChinese=YES;
    for (int i =0; i<_string.length; i++)
    {
        if ([[_string substringWithRange:NSMakeRange(i,1)] dataUsingEncoding:NSASCIIStringEncoding])
        {
            return NO;
        }
        else
        {
            bChinese=YES;
        }
    }
    return bChinese;
}

int checkIDfromchar (const char *sPaperId)
{
    if( 18 != strlen(sPaperId)) return 0;  //检验长度
    long lSumQT =0;
    int R[] ={7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 };   //加权因子
    char sChecker[11]={'1','0','X', '9', '8', '7', '6', '5', '4', '3', '2'};  //校验码
    //校验数字
    for (int i=0; i<18; i++){
        if ( !isdigit(sPaperId[i]) && !('X' == sPaperId[i] && 17 == i) ) {
            return 0;
        }
    }
    //验证最末的校验码
    for (int i=0; i<=16; i++)  {
        lSumQT += (sPaperId[i]-48) * R[i];
    }
    if (sChecker[lSumQT%11] != sPaperId[17] ){
        return 0;
    }
    return 1;
}

//判断邮箱是否合法
+(BOOL)validateEmail:(NSString*)email{

    if( (0 != [email rangeOfString:@"@"].length) &&  (0 != [email rangeOfString:@"."].length) )
    {
        NSMutableCharacterSet *invalidCharSet = [[[NSCharacterSet alphanumericCharacterSet] invertedSet]mutableCopy];
        [invalidCharSet removeCharactersInString:@"_-"];

        NSRange range1 = [email rangeOfString:@"@" options:NSCaseInsensitiveSearch];

        // If username part contains any character other than "."  "_" "-"

        NSString *usernamePart = [email substringToIndex:range1.location];
        NSArray *stringsArray1 = [usernamePart componentsSeparatedByString:@"."];
        for (NSString *string in stringsArray1) {
            NSRange rangeOfInavlidChars=[string rangeOfCharacterFromSet: invalidCharSet];
            if(rangeOfInavlidChars.length !=0 || [string isEqualToString:@""])
                return NO;
        }

        NSString *domainPart = [email substringFromIndex:range1.location+1];
        NSArray *stringsArray2 = [domainPart componentsSeparatedByString:@"."];

        for (NSString *string in stringsArray2) {
            NSRange rangeOfInavlidChars=[string rangeOfCharacterFromSet:invalidCharSet];
            if(rangeOfInavlidChars.length !=0 || [string isEqualToString:@""])
                return NO;
        }

        return YES;
    }
    else // no ''@'' or ''.'' present
        return NO;
}

/*  返回信用卡有效期的年份
 *  返回参数:当前年份往后二十年内
 *
 */
+(NSMutableArray *)getCreditCardExpiryYearArray
{
    NSDateFormatter *formatter=[[NSDateFormatter alloc] init];
    NSTimeZone *zone=[NSTimeZone timeZoneWithName:@"Asia/Shanghai"];
    [formatter setTimeZone:zone];
    [formatter setDateFormat:@"yyyy"];
    NSInteger year=[[formatter stringFromDate:[NSDate date]] intValue];

    NSMutableArray *returnArray=[[NSMutableArray alloc] init];
    for (int i=0; i<20; i++) {
        NSString *strYear=[NSString stringWithFormat:@"%d年",(int)(year+i)];
        [returnArray addObject:strYear];
    }

    return returnArray;
}

/*
 *  返回信用卡有效期的月份
 *  返回参数:当月往后到年底
 */

//+(NSMutableArray *)getCreditCardExpiryMonthArray:(NSInteger)_index{
//    if (_index == 0) {
//        NSInteger month = [[TCDateFormatter dateToStringCustom:[NSDate date] formatString:def_Month] integerValue];
//        NSMutableArray *returnArray=[[NSMutableArray alloc] init];
//        for (int i = (int)month; i<=12; i++) {
//            if (i<=9) {
//                NSString *strMonth=[NSString stringWithFormat:@"0%d月",i];
//                [returnArray addObject:strMonth];
//            }else{
//                NSString *strMonth=[NSString stringWithFormat:@"%d月",i];
//                [returnArray addObject:strMonth];
//            }
//        }
//        return returnArray;
//    }else{
//        NSMutableArray *returnArray=[[NSMutableArray alloc] initWithObjects:@"01月",@"02月",@"03月",@"04月",@"05月",@"06月",@"07月",@"08月",@"09月",@"10月",@"11月",@"12月", nil];
//        return returnArray;
//    }
//}

@end


text:
#pragma once
#include <memory>
#include <utility>
#include "util/list.h"
#include "util/sexpr/options.h"
#include "kernel/metavar.h"

namespace lean {
/** \brief Functional object for (incomplete) higher-order unification */
class ho_unifier {
    class imp;
    std::unique_ptr<imp> m_ptr;
public:
    ho_unifier(environment const & env, options const & opts = options());
    ~ho_unifier();

    typedef list<std::tuple<context, expr, expr>> residue;
    typedef std::pair<metavar_env, residue> result;

    /**
        \brief Try to unify \c l and \c r in the context \c ctx using the input substitution \c menv.
        By unification, we mean we have to find an assignment for the unassigned metavariables in
        \c l and \c r s.t. \c l and \c r become definitionally equal.
        The unifier may produce a residue: a set of unification problems
        that could not be solved, and were postponed. The unifier postpones unification problems of the form
        <tt>(?M1 ...) == (?M2 ...)</tt> where \c M1 and \c M2 are unassigned metavariables.
        The result is a list of pairs: substitution (in the form of \c metavar_env) and residue.
        Each pair is a possible solution. The resultant \c metavar_env may contain new metavariables.
        The empty list represents failure.
    */
    list<result> operator()(context const & ctx, expr const & l, expr const & r, metavar_env const & menv);

    void set_interrupt(bool flag);
    void interrupt() { set_interrupt(true); }
    void reset_interrupt() { set_interrupt(false); }
};
}


text:
_[www.codever.land/bookmarks/t/operating-system](https://www.codever.land/bookmarks/t/operating-system)_
---
#### [Rust OS Comparison](https://github.com/flosse/rust-os-comparison)
_https://github.com/flosse/rust-os-comparison_

A comparison of operating systems written in Rust
* **tags**: [rust](../tagged/rust.md), [operating-system](../tagged/operating-system.md)
* :octocat: **[source code](https://github.com/flosse/rust-os-comparison)**
---
#### [redox-os/redox](https://gitlab.redox-os.org/redox-os/redox)
_https://gitlab.redox-os.org/redox-os/redox_

[](https://travis-ci.org/redox-os/redox)
* **tags**: [rust](../tagged/rust.md), [operating-system](../tagged/operating-system.md)
---
#### [thepowersgang/rust_os](https://github.com/thepowersgang/rust_os)
_https://github.com/thepowersgang/rust_os_

[](https://travis-ci.org/thepowersgang/rust_os)
* **tags**: [rust](../tagged/rust.md), [operating-system](../tagged/operating-system.md)
* :octocat: **[source code](https://github.com/thepowersgang/rust_os)**
---
#### [tock/tock](https://github.com/tock/tock)
_https://github.com/tock/tock_

A secure embedded operating system for Cortex-M based microcontrollers
* **tags**: [rust](../tagged/rust.md), [operating-system](../tagged/operating-system.md)
* :octocat: **[source code](https://github.com/tock/tock)**
---
#### [nebulet/nebulet](https://github.com/nebulet/nebulet)
_https://github.com/nebulet/nebulet_

A microkernel that implements a WebAssembly "usermode" that runs in Ring 0.
* **tags**: [rust](../tagged/rust.md), [operating-system](../tagged/operating-system.md)
* :octocat: **[source code](https://github.com/nebulet/nebulet)**
---
#### [CoreOS](http://coreos.com)
_http://coreos.com_

Learn more about how CoreOS and Red Hat have joined forces to extend the value of containers and Kubernetes with OpenShift Container Platform.
* **tags**: [kubernetes](../tagged/kubernetes.md), [operating-system](../tagged/operating-system.md)
---
#### [GCI](https://cloud.google.com/container-optimized-os/docs/)
_https://cloud.google.com/container-optimized-os/docs/_

OS image optimized for running containers on Google Cloud Platform.
* **tags**: [kubernetes](../tagged/kubernetes.md), [operating-system](../tagged/operating-system.md)
---
#### [k3OS](https://github.com/rancher/k3os)
_https://github.com/rancher/k3os_

Purpose built OS for Kubernetes, fully managed by Kubernetes. - rancher/k3os
* **tags**: [kubernetes](../tagged/kubernetes.md), [operating-system](../tagged/operating-system.md)
* :octocat: **[source code](https://github.com/rancher/k3os)**
---
#### [Kurma](https://github.com/apcera/kurma)
_https://github.com/apcera/kurma_

Kurma - Containers all the way down. Contribute to apcera/kurma development by creating an account on GitHub.
* **tags**: [kubernetes](../tagged/kubernetes.md), [operating-system](../tagged/operating-system.md)
* :octocat: **[source code](https://github.com/apcera/kurma)**
---
#### [LinuxKit](https://github.com/linuxkit/kubernetes)
_https://github.com/linuxkit/kubernetes_

minimal and immutable Kubernetes images built with LinuxKit - linuxkit/kubernetes
* **tags**: [kubernetes](../tagged/kubernetes.md), [operating-system](../tagged/operating-system.md)
* :octocat: **[source code](https://github.com/linuxkit/kubernetes)**
---
#### [Talos](https://github.com/talos-systems/talos)
_https://github.com/talos-systems/talos_

A modern operating system for Kubernetes. Contribute to talos-systems/talos development by creating an account on GitHub.
* **tags**: [kubernetes](../tagged/kubernetes.md), [operating-system](../tagged/operating-system.md)
* :octocat: **[source code](https://github.com/talos-systems/talos)**
---
#### [المقدمة في تحليل وتصميم أنظمة ](http://librebooks.org/intro-to-os-analysis-and-design/)
_http://librebooks.org/intro-to-os-analysis-and-design/_

* **tags**: [free-programming-books](../tagged/free-programming-books.md), [operating-system](../tagged/operating-system.md), [free-programming-books-ar](../tagged/free-programming-books-ar.md)
---
#### [Sistemas Operativos](http://exa.unne.edu.ar/depar/areas/informatica/SistemasOperativos/sistope2.PDF)
_http://exa.unne.edu.ar/depar/areas/informatica/SistemasOperativos/sistope2.PDF_

Dr. David Luis la Red (PDF)
* **tags**: [free-programming-books](../tagged/free-programming-books.md), [operating-system](../tagged/operating-system.md), [free-programming-books-es](../tagged/free-programming-books-es.md)
---
#### [Fundamentos de Sistemas Operativos](http://sistop.org/pdf/sistemas_operativos.pdf)
_http://sistop.org/pdf/sistemas_operativos.pdf_

Gunnar Wolf et al (PDF)
* **tags**: [free-programming-books](../tagged/free-programming-books.md), [operating-system](../tagged/operating-system.md), [free-programming-books-es](../tagged/free-programming-books-es.md)
---
#### [Xv6, a simple Unix-like teaching operating system](https://pdos.csail.mit.edu/6.828/2012/xv6.html)
_https://pdos.csail.mit.edu/6.828/2012/xv6.html_

* **tags**: [free-programming-books](../tagged/free-programming-books.md), [operating-system](../tagged/operating-system.md)
---
#### [Writing a Simple Operating System from Scratch](http://www.cs.bham.ac.uk/~exr/lectures/opsys/10_11/lectures/os-dev.pdf)
_http://www.cs.bham.ac.uk/~exr/lectures/opsys/10_11/lectures/os-dev.pdf_

Nick Blundell (PDF)
* **tags**: [free-programming-books](../tagged/free-programming-books.md), [operating-system](../tagged/operating-system.md)
---
#### [UNIX Application and System Programming, lecture notes](http://www.compsci.hunter.cuny.edu/~sweiss/course_materials/unix_lecture_notes.php)
_http://www.compsci.hunter.cuny.edu/~sweiss/course_materials/unix_lecture_notes.php_

Prof. Stewart Weiss (PDF)
* **tags**: [free-programming-books](../tagged/free-programming-books.md), [operating-system](../tagged/operating-system.md)
---
#### [Think OS: A Brief Introduction to Operating Systems](http://www.greenteapress.com/thinkos/index.html)
_http://www.greenteapress.com/thinkos/index.html_

Allen B. Downey (PDF)
* **tags**: [free-programming-books](../tagged/free-programming-books.md), [operating-system](../tagged/operating-system.md)
---
#### [The Little Book of Semaphores](http://greenteapress.com/semaphores/)
_http://greenteapress.com/semaphores/_

Allen B. Downey
* **tags**: [free-programming-books](../tagged/free-programming-books.md), [operating-system](../tagged/operating-system.md)
---
#### [The little book about OS development](https://littleosbook.github.io)
_https://littleosbook.github.io_

Erik Helin, Adam Renberg
* **tags**: [free-programming-books](../tagged/free-programming-books.md), [operating-system](../tagged/operating-system.md)
---
#### [The Design and Implementation of the Anykernel and Rump Kernels](http://www.fixup.fi/misc/rumpkernel-book/)
_http://www.fixup.fi/misc/rumpkernel-book/_

Antti Kantee
* **tags**: [free-programming-books](../tagged/free-programming-books.md), [operating-system](../tagged/operating-system.md)
---
#### [The Art of Unix Programming](http://catb.org/esr/writings/taoup/html/)
_http://catb.org/esr/writings/taoup/html/_

Eric S. Raymond
* **tags**: [free-programming-books](../tagged/free-programming-books.md), [operating-system](../tagged/operating-system.md)
---
#### [Project Oberon: The Design of an Operating System, a Compiler, and a Computer](http://people.inf.ethz.ch/wirth/ProjectOberon/index.html)
_http://people.inf.ethz.ch/wirth/ProjectOberon/index.html_

Niklaus Wirth & Jürg Gutknecht (PDF)
* **tags**: [free-programming-books](../tagged/free-programming-books.md), [operating-system](../tagged/operating-system.md)
---
#### [Practical File System Design: The Be File System](http://www.nobius.org/~dbg/practical-file-system-design.pdf)
_http://www.nobius.org/~dbg/practical-file-system-design.pdf_

Dominic Giampaolo (PDF)
* **tags**: [free-programming-books](../tagged/free-programming-books.md), [operating-system](../tagged/operating-system.md)
---
#### [Operating Systems Concept 9th edition](http://codex.cs.yale.edu/avi/os-book/OS9/slide-dir/)
_http://codex.cs.yale.edu/avi/os-book/OS9/slide-dir/_

Avi Silberschatz, Peter Baer, Galvin Greg Gagne (PDF)
* **tags**: [free-programming-books](../tagged/free-programming-books.md), [operating-system](../tagged/operating-system.md)
---
#### [Operating Systems and Middleware](https://gustavus.edu/mcs/max/os-book/)
_https://gustavus.edu/mcs/max/os-book/_

(PDF and LaTeX)
* **tags**: [free-programming-books](../tagged/free-programming-books.md), [operating-system](../tagged/operating-system.md)
---
#### [How to write a simple operating system in assembly language](http://mikeos.sourceforge.net/write-your-own-os.html)
_http://mikeos.sourceforge.net/write-your-own-os.html_

Mike Saunders (HTML)
* **tags**: [free-programming-books](../tagged/free-programming-books.md), [operating-system](../tagged/operating-system.md)
---
#### [How to Make a Computer Operating System (Work in Progress)](https://github.com/SamyPesse/How-to-Make-a-Computer-Operating-System)
_https://github.com/SamyPesse/How-to-Make-a-Computer-Operating-System_

* **tags**: [free-programming-books](../tagged/free-programming-books.md), [operating-system](../tagged/operating-system.md)
---
#### [Computer Science from the Bottom Up](http://www.bottomupcs.com)
_http://www.bottomupcs.com_

* **tags**: [free-programming-books](../tagged/free-programming-books.md), [operating-system](../tagged/operating-system.md)
---
#### [鸟哥的 Linux 私房菜 服务器架设篇](http://cn.linux.vbird.org/linux_server/)
_http://cn.linux.vbird.org/linux_server/_

* **tags**: [free-programming-books](../tagged/free-programming-books.md), [free-programming-books-zh](../tagged/free-programming-books-zh.md), [operating-system](../tagged/operating-system.md)
---
#### [鸟哥的 Linux 私房菜 基础学习篇](http://cn.linux.vbird.org/linux_basic/linux_basic.php)
_http://cn.linux.vbird.org/linux_basic/linux_basic.php_

* **tags**: [free-programming-books](../tagged/free-programming-books.md), [free-programming-books-zh](../tagged/free-programming-books-zh.md), [operating-system](../tagged/operating-system.md)
---
#### [理解Linux进程](https://github.com/tobegit3hub/understand_linux_process)
_https://github.com/tobegit3hub/understand_linux_process_

* **tags**: [free-programming-books](../tagged/free-programming-books.md), [free-programming-books-zh](../tagged/free-programming-books-zh.md), [operating-system](../tagged/operating-system.md)
---
#### [开源世界旅行手册](http://i.linuxtoy.org/docs/guide/index.html)
_http://i.linuxtoy.org/docs/guide/index.html_

* **tags**: [free-programming-books](../tagged/free-programming-books.md), [free-programming-books-zh](../tagged/free-programming-books-zh.md), [operating-system](../tagged/operating-system.md)
---
#### [嵌入式 Linux 知识库 (eLinux.org 中文版)](https://tinylab.gitbooks.io/elinux/content/zh/)
_https://tinylab.gitbooks.io/elinux/content/zh/_

* **tags**: [free-programming-books](../tagged/free-programming-books.md), [free-programming-books-zh](../tagged/free-programming-books-zh.md), [operating-system](../tagged/operating-system.md)
---
#### [命令行的艺术](https://github.com/jlevy/the-art-of-command-line/blob/master/README-zh.md)
_https://github.com/jlevy/the-art-of-command-line/blob/master/README-zh.md_

* **tags**: [free-programming-books](../tagged/free-programming-books.md), [free-programming-books-zh](../tagged/free-programming-books-zh.md), [operating-system](../tagged/operating-system.md)
---
#### [UNIX TOOLBOX](http://cb.vu/unixtoolbox_zh_CN.xhtml)
_http://cb.vu/unixtoolbox_zh_CN.xhtml_

* **tags**: [free-programming-books](../tagged/free-programming-books.md), [free-programming-books-zh](../tagged/free-programming-books-zh.md), [operating-system](../tagged/operating-system.md)
---
#### [uCore Lab: Operating System Course in Tsinghua University](https://www.gitbook.com/book/objectkuan/ucore-docs/details)
_https://www.gitbook.com/book/objectkuan/ucore-docs/details_

* **tags**: [free-programming-books](../tagged/free-programming-books.md), [free-programming-books-zh](../tagged/free-programming-books-zh.md), [operating-system](../tagged/operating-system.md)
---
#### [Ubuntu 参考手册 ](http://wiki.ubuntu.org.cn/UbuntuManual)
_http://wiki.ubuntu.org.cn/UbuntuManual_

* **tags**: [free-programming-books](../tagged/free-programming-books.md), [free-programming-books-zh](../tagged/free-programming-books-zh.md), [operating-system](../tagged/operating-system.md)
---
#### [The Linux Command Line](http://billie66.github.io/TLCL/index.html)
_http://billie66.github.io/TLCL/index.html_

(中英文版)
* **tags**: [free-programming-books](../tagged/free-programming-books.md), [free-programming-books-zh](../tagged/free-programming-books-zh.md), [operating-system](../tagged/operating-system.md)
---
#### [Operating Systems: Three Easy Pieces](http://pages.cs.wisc.edu/~remzi/OSTEP/)
_http://pages.cs.wisc.edu/~remzi/OSTEP/_

* **tags**: [free-programming-books](../tagged/free-programming-books.md), [free-programming-books-zh](../tagged/free-programming-books-zh.md), [operating-system](../tagged/operating-system.md)
---
#### [Mac 开发配置手册](https://aaaaaashu.gitbooks.io/mac-dev-setup/content/)
_https://aaaaaashu.gitbooks.io/mac-dev-setup/content/_

* **tags**: [free-programming-books](../tagged/free-programming-books.md), [free-programming-books-zh](../tagged/free-programming-books-zh.md), [operating-system](../tagged/operating-system.md)
---
#### [Linux工具快速教程](https://github.com/me115/linuxtools_rst)
_https://github.com/me115/linuxtools_rst_

* **tags**: [free-programming-books](../tagged/free-programming-books.md), [free-programming-books-zh](../tagged/free-programming-books-zh.md), [operating-system](../tagged/operating-system.md)
---
#### [Linux 系统高级编程](http://sourceforge.net/projects/elpi/)
_http://sourceforge.net/projects/elpi/_

* **tags**: [free-programming-books](../tagged/free-programming-books.md), [free-programming-books-zh](../tagged/free-programming-books-zh.md), [operating-system](../tagged/operating-system.md)
---
#### [Linux 构建指南](http://works.jinbuguo.com/lfs/lfs62/index.html)
_http://works.jinbuguo.com/lfs/lfs62/index.html_

* **tags**: [free-programming-books](../tagged/free-programming-books.md), [free-programming-books-zh](../tagged/free-programming-books-zh.md), [operating-system](../tagged/operating-system.md)
---
#### [Linux Guide for Complete Beginners](http://happypeter.github.io/LGCB/book/)
_http://happypeter.github.io/LGCB/book/_

* **tags**: [free-programming-books](../tagged/free-programming-books.md), [free-programming-books-zh](../tagged/free-programming-books-zh.md), [operating-system](../tagged/operating-system.md)
---
#### [Linux Documentation (中文版)](https://tinylab.gitbooks.io/linux-doc/content/zh-cn/)
_https://tinylab.gitbooks.io/linux-doc/content/zh-cn/_

* **tags**: [free-programming-books](../tagged/free-programming-books.md), [free-programming-books-zh](../tagged/free-programming-books-zh.md), [operating-system](../tagged/operating-system.md)
---
#### [FreeRADIUS新手入门](http://freeradius.akagi201.org)
_http://freeradius.akagi201.org_

* **tags**: [free-programming-books](../tagged/free-programming-books.md), [free-programming-books-zh](../tagged/free-programming-books-zh.md), [operating-system](../tagged/operating-system.md)
---
#### [FreeBSD 使用手册](http://www.freebsd.org/doc/zh_CN.UTF-8/books/handbook/)
_http://www.freebsd.org/doc/zh_CN.UTF-8/books/handbook/_

* **tags**: [free-programming-books](../tagged/free-programming-books.md), [free-programming-books-zh](../tagged/free-programming-books-zh.md), [operating-system](../tagged/operating-system.md)
---
#### [Docker入门实战](http://yuedu.baidu.com/ebook/d817967416fc700abb68fca1)
_http://yuedu.baidu.com/ebook/d817967416fc700abb68fca1_

* **tags**: [free-programming-books](../tagged/free-programming-books.md), [free-programming-books-zh](../tagged/free-programming-books-zh.md), [operating-system](../tagged/operating-system.md)
---
#### [Docker中文指南](https://github.com/widuu/chinese_docker)
_https://github.com/widuu/chinese_docker_

* **tags**: [free-programming-books](../tagged/free-programming-books.md), [free-programming-books-zh](../tagged/free-programming-books-zh.md), [operating-system](../tagged/operating-system.md)
---
#### [Docker —— 从入门到实践](https://github.com/yeasy/docker_practice)
_https://github.com/yeasy/docker_practice_

* **tags**: [free-programming-books](../tagged/free-programming-books.md), [free-programming-books-zh](../tagged/free-programming-books-zh.md), [operating-system](../tagged/operating-system.md)
---
#### [Debian 参考手册 ](http://man.chinaunix.net/linux/debian/reference/reference.zh-cn.html)
_http://man.chinaunix.net/linux/debian/reference/reference.zh-cn.html_

* **tags**: [free-programming-books](../tagged/free-programming-books.md), [free-programming-books-zh](../tagged/free-programming-books-zh.md), [operating-system](../tagged/operating-system.md)
---


text:
package net.bytebuddy.dynamic.scaffold;

import org.junit.Test;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;

import static org.mockito.Mockito.*;

public class TypeWriterDefaultForInliningWithFullProcessingInitializationHandlerAppendingFrameWriterExpandingTest {

    @Test
    public void testFrame() throws Exception {
        TypeWriter.Default.ForInlining.WithFullProcessing.InitializationHandler.Appending.FrameWriter.Expanding.INSTANCE.onFrame(0, 0);
        MethodVisitor methodVisitor = mock(MethodVisitor.class);
        TypeWriter.Default.ForInlining.WithFullProcessing.InitializationHandler.Appending.FrameWriter.Expanding.INSTANCE.emitFrame(methodVisitor);
        verify(methodVisitor).visitFrame(Opcodes.F_NEW, 0, new Object[0], 0, new Object[0]);
        verifyNoMoreInteractions(methodVisitor);
    }
}


text:
package org.neo4j.kernel.api.constraints;

import org.neo4j.graphdb.DynamicLabel;
import org.neo4j.graphdb.schema.ConstraintDefinition;
import org.neo4j.graphdb.schema.ConstraintType;
import org.neo4j.kernel.api.ReadOperations;
import org.neo4j.kernel.api.StatementTokenNameLookup;
import org.neo4j.kernel.api.TokenNameLookup;
import org.neo4j.kernel.impl.coreapi.schema.InternalSchemaActions;
import org.neo4j.kernel.impl.coreapi.schema.UniquenessConstraintDefinition;

public class UniquenessConstraint extends NodePropertyConstraint
{
    public UniquenessConstraint( int labelId, int propertyKeyId )
    {
        super( labelId, propertyKeyId );
    }

    @Override
    public void added( ChangeVisitor visitor )
    {
        visitor.visitAddedUniquePropertyConstraint( this );
    }

    @Override
    public void removed( ChangeVisitor visitor )
    {
        visitor.visitRemovedUniquePropertyConstraint( this );
    }

    @Override
    public ConstraintDefinition asConstraintDefinition( InternalSchemaActions schemaActions, ReadOperations readOps )
    {
        StatementTokenNameLookup lookup = new StatementTokenNameLookup( readOps );
        return new UniquenessConstraintDefinition( schemaActions,
                DynamicLabel.label( lookup.labelGetName( labelId ) ),
                lookup.propertyKeyGetName( propertyKeyId ) );
    }

    @Override
    public ConstraintType type()
    {
        return ConstraintType.UNIQUENESS;
    }

    @Override
    public String userDescription( TokenNameLookup tokenNameLookup )
    {
        String labelName = tokenNameLookup.labelGetName( labelId );
        String boundIdentifier = labelName.toLowerCase();
        return String.format( "CONSTRAINT ON ( %s:%s ) ASSERT %s.%s IS UNIQUE",
                boundIdentifier, labelName, boundIdentifier, tokenNameLookup.propertyKeyGetName( propertyKeyId ) );
    }

    @Override
    public String toString()
    {
        return String.format( "CONSTRAINT ON ( n:label[%s] ) ASSERT n.property[%s] IS UNIQUE",
                labelId, propertyKeyId );
    }
}


text:
package android.widget;

public class Toast {
  public Toast(Context context);

  public final static int LENGTH_LONG = 1;
  public final static int LENGTH_SHORT = 0;

  public static Toast makeText(Context context, CharSequence text, int duration);

  public void show();
}


text:
<!DOCTYPE html>
<html>
	<head>
		<meta charset="<?php bloginfo( 'charset' ); ?>">
		<title><?php wp_title( ' | ', true, 'right' ); ?></title>
		<?php wptouch_head(); ?>
	</head>

	<!-- Help speed up display of the page -->
	<?php flush(); ?>

	<body <?php body_class( wptouch_get_body_classes() ); ?>>

		<?php do_action( 'wptouch_preview' ); ?>

		<?php do_action( 'wptouch_body_top' ); ?>

		<?php get_template_part( 'header-bottom' ); ?>