⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 markarray.java

📁 经典的货郎担问题解决办法
💻 JAVA
字号:
/*** This code was written by Kent Paul Dolan.  See accompanying file** TravellerDoc.html for status for your use.*/package com.well.www.user.xanthian.java.tools;public class MarkArray{  private boolean m_marks[] = null;  private int     m_setCount = 0;  public MarkArray( int size )   {    m_marks = new boolean[ size ];    for ( int i=0; i<size; i++ ) { m_marks[i] = false; }    m_setCount = 0;  }  public synchronized void setAllMarksTrue()  {    for ( int i=0; i<m_marks.length; i++ ) { m_marks[i] = true; }    m_setCount = m_marks.length;  }  public synchronized void setAllMarksFalse()  {    for ( int i=0; i<m_marks.length; i++ ) { m_marks[i] = false; }    m_setCount = 0;  }  public synchronized boolean setMarkAndCheckIfAllMarksAreSet( int index )  {    if ( m_marks[ index ] == false )    {      m_setCount++;      m_marks[ index ] = true;    }    if ( m_setCount == m_marks.length )    {      return true;    }    else    {      return false;    }  }  public synchronized boolean clearMarkAndCheckIfAllMarksAreClear( int index )  {    if ( m_marks[ index ] == true )    {      m_setCount--;      m_marks[ index ] = false;    }    if ( m_setCount == 0 )    {      return true;    }    else    {      return false;    }  }  public synchronized void clear( int index )  {    m_marks[ index ] = false;  }  public synchronized void set( int index )  {    m_marks[ index ] = true;  }  public synchronized int getCount()  {    return m_setCount;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -